We have two AlertDialog objects
AlertDialog dialog1, dialog2;
both dialogs are created via AlertDialog.Builder.
How can we recognize which dialog is source of event in DialogInterface.OnClickListener ?
with single dialog we can do this:
AlertDialogInstance.setOnClickListener(myListener);
//myListener
public void onClick(DialogInterface arg0, int arg1) {
switch (arg1) {
case AlertDialog.BUTTON_NEGATIVE:
// do something
break;
case AlertDialog.BUTTON_POSITIVE:
// do something
break;
case AlertDialog.BUTTON_NEUTRAL:
// do something
break;
}
}
how to modify this switch logic to handle multiple dialogs?
(Or if there is better system to handle dialogs, other than inline button callbacks, what is it?)
I’ll recommend you to put needed param in the custom listener.
Then, when you add onClickListeners to dialogs, you just provide an id to listener.