I try to 'develop' an Android application with C# (VS2010 + dot42/mono) which shows lots od messages, gets users' input, and creates AlertDialogs. The questions are: 1. Do you know how to catch OnCancel Event returned from Android AlertDialog(s)? 2. How to detect which exactly AlertDialog sent it?
To be more clear, I am trying to get the AlertDialog.Builder SetOnCancelListener(IDialogInterface_IOnCancelListener onCancelListener) to work.
I have created a method which displays a simple message box, and I try to catch somehow (but it is all wrong so far) the onCancel event. Please see below. Can you help me?
private void button2_OnClick(object sender, EventArgs eventArgs)
{
AlertDialog.Builder a_builder = new AlertDialog.Builder(this);
a_builder.SetMessage("Is this all?");
a_builder.SetTitle("Question");
a_builder.SetPositiveButton("Yes", OnMsgClick_Result2 );
a_builder.SetNegativeButton("Not yet" OnMsgClick_Result2);
a_builder.SetCancelable(true);
a_builder.SetOnCancelListener(
new IDialogInterface_IOnCancelListener(
new IDialogInterface_IOnClickListener(IDialogInterface dialog) {
switch (dialog.which) //<--------- ???
{
case _dialogA:
text1.settext("DialogA was canceled");
break;
case _dialogB:
text1.settext("DialogB was canceled");
break;
default:
text1.settext("Nothing has been canceled");
break;
}
})
); //<--- ??? ERROR HERE of course
a_builder.Create().Show();
}