In my Android app, I have a dialog with a few options, one of which should result in the current dialog being displayed again.
It’s like this:
protected Dialog onCreateDialog(int id) {
AlertDialog.Builder builder = new AlertDialog.Builder(this);
if (id == 0) {
builder.setMessage("Message 0")
.setPositiveButton("Show Message 0 Again", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
showDialog(0);
}
})
.setNegativeButton("Show Message 1", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
showDialog(1);
}
});
} else {
builder.setMessage("Message 1")
.setPositiveButton("Dismiss", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
// nothing
}
});
}
AlertDialog dialog = builder.create();
return dialog;
}
However, when I click on the “Show Message 0 Again” button, the dialog is dismissed and does not appear again. The “Show Message 1” button works fine.
I would prefer the dialog to actually be dismissed and then opened again, rather than simply having the “Show Message 0 Again” button just not do anything and not cause the dialog to be dismissed, if that’s possible.
Here is the discussion : Dialog.show() vs. Activity.showDialog()
Please Have a look on that…
Hopes it Helps. 🙂