Identify which AlertDialog triggered onClick(DialogInterface dialog, int which)
- by Kurian
I'm creating a dialog as follows:
@Override
protected Dialog onCreateDialog(int id) {
switch (id) {
case DIALOG_1:
return new AlertDialog.Builder(this)
.setTitle(R.string.s_dlg1)
.setPositiveButton(android.R.string.ok, this)
.create();
case DIALOG_2:
...
...
}
return null;
}
@Override
public void onClick(DialogInterface dialog, int whichButton) {
if (dialog == ???) {
...
}
else if (dialog == ???){
...
}
}
How do I identify which dialog triggered the onClick method? I can't declare the interface methods as in-line when creating the dialog because I want to access variables in my class. Every other interface passes some sort of id to its methods to identify which object called the method, but I can't seem to do anything with 'DialogInterface dialog'.