0
I do a check and play 3 dialogs on the screen, but if the user cancels one of them, they should all close. Does anyone know how to do this? I don’t even know if it’s possible. I thank you in advance.
0
I do a check and play 3 dialogs on the screen, but if the user cancels one of them, they should all close. Does anyone know how to do this? I don’t even know if it’s possible. I thank you in advance.
1
Of course it is possible, if you have a reference to the three dialogs created, just you intercept the click on one of them and do something like:
dialog1.dismiss();
dialog2.dismiss();
dialog3.dismiss();
Well, a full example would be like this:
AlertDialog.Builder builder1 = new AlertDialog.Builder(this);
builder1.setMessage("Exemplo");
builder1.setPositiveButton("Sim", null);
builder1.setNegativeButton("Não", null);
final AlertDialog dialog1 = builder1.show();
AlertDialog.Builder builder2 = new AlertDialog.Builder(this);
builder2.setMessage("Exemplo");
builder2.setPositiveButton("Sim", null);
builder2.setNegativeButton("Não", null);
final AlertDialog dialog2 = builder2.show();
AlertDialog.Builder builder3 = new AlertDialog.Builder(this);
builder3.setMessage("Exemplo");
builder3.setPositiveButton("Sim", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog3, int i) {
dialog3.dismiss();
dialog1.dismiss();
dialog2.dismiss();
}
});
builder3.setNegativeButton("Não", null);
AlertDialog dialog3 = builder3.show();
By clicking on the yes of dialog3
, the three dialogs will be closed.
Browser other questions tagged android dialog
You are not signed in. Login or sign up in order to post.
You can post a preview of your code?
– user28595