-1

I am navigating from one dialog to other, likewise I traversed from three dialogs. Now I want to dismiss all opened dialogs from last dialog click and refresh the fragment.

Is there any simple way to do this? All helps will be appreciated. Thanks

Uma Achanta
  • 3,669
  • 4
  • 22
  • 49

1 Answers1

2

Keep references of all dialogs and dismiss them in last dialog click.

AlertDialog dialog1 = new AlertDialog.Builder().build();

AlertDialog dialog2 = new AlertDialog.Builder().build();

AlertDialog dialog3 = new AlertDialog.Builder()
             .setPositiveButton("Close", new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int id) {
                    // if this button is clicked,
                    // dismiss all dialogs
                    dialog1.dismiss();
                    dialog2.dismiss();
                    dialog3.dismiss();
                }
              }).build();