I created a generic OkCancelDialog class that is conveniently invoked throughout my app via a static method:
static public void Prompt(String title, String message) {
OkCancelDialog okcancelDialog = new OkCancelDialog();
okcancelDialog.showAlert(title, message);
}
For various reasons I need the onClick listener in the activity, so in the activity I have:
public void onClick(DialogInterface v, int buttonId) {
if (buttonId == DialogInterface.BUTTON_POSITIVE) { // OK button
// do the OK thing
}
else if (buttonId == DialogInterface.BUTTON_NEGATIVE) { // CANCEL button
// do the Cancel thing
}
else {
// should never happen
}
}
This works great with a single dialog in the app, but now I want to add another OK/Cancel dialog, handled by the same activity. As far as I can tell, only one onClick() can be defined for the activity, so I am not sure how to go about implementing this.
Any suggestions or tips?
Try something like this…
EDIT This is how I create my
AlertDialogs…