Reputation: 493
I declare AlertDialog:
AlertDialog.Builder alertConfirmTransfer = new AlertDialog.Builder(this);
alertConfirmTransfer.SetMessage("Some message");
alertConfirmTransfer.SetPositiveButton("YES", delegate
{
alertConfirmTransfer.Dispose();
});
alertConfirmTransfer.SetNegativeButton("NO", delegate
{
alertConfirmTransfer.Dispose();
});
Dialog dialogConfirmTransfer = alertConfirmTransfer.Create();
dialogConfirmTransfer.Show();
When the dialog appears and I click yes or no the dialog disappears but if in the SetPositiveButton I put a try-catch block under
alertConfirmTransfer.Dispose();
nad the try'catch slows down when I click Yes button, the dialog stays on screen
Upvotes: 0
Views: 1176
Reputation: 1534
You actually have to dismiss the dialog by using the Cancel() method.
Declare the local variable Dialog dialogConfirmTransfer
above the AlertDialog.Builder. Initialize it the same way as you do now. And call dialogConfirmTranser.Cancel()
in the delegates for your buttons.
Upvotes: 2