在 Xamarin Android 中创建一个需要单击 3 次的按钮。
到目前为止有以下,但不工作
我已经在主要活动中创建了这个,并在表单上使用了一个按钮
但是,当单击按钮时(单击一次时确实有效)现在不起作用
public async void DepositAsync(object sender, EventArgs eventArgs)
int counter = 0;
{
if (Security.IsDeposited) return;
bool result = await Security.Deposit(EnteredAmount.Text);
{
if (counter == 1)
{
Toast.MakeText(this, "Please click button twice", ToastLength.Long).Show();
}
else if (counter == 2)
{
Toast.MakeText(this, "Triple click to confirm deposit", ToastLength.Long).Show();
}
else if (counter == 3)
{
if (result)
{
Toast.MakeText(this, "Deposit Successfully", ToastLength.Long).Show();
StartActivity(new Intent(this, typeof(MainActivity)));
ValidationText.Text = "Success!";
ValidationText.SetTextColor(new Color(20, 230, 20));
}
else
{
Animation shake = AnimationUtils.LoadAnimation(this, Resource.Animation.shake);
ValidationText.Text = "Cannot Deposit...please try again";
ValidationText.SetTextColor(new Color(230, 20, 20));
ValidationText.StartAnimation(shake);
ConfirmDeposit.StartAnimation(shake);
EnteredAmount.StartAnimation(shake);
}
}
}
}