JLT
JLT

Reputation: 3182

How To Show Multiple Alert Dialogs In Android

I have one AlertDialog that shows three buttons: CANCEL, SHOW CONFIRMATION, OK.

When the SHOW CONFIRMATION is selected, I want another AlertDialog to appear, BUT maintaining the first AlertDialog.

How can this be done???

I tried to not call dialog.dismiss, but still , when the second one appears, the first one will be dismissed automatically.

Please help. Many Thanks!

Upvotes: 1

Views: 1976

Answers (1)

Don Chakkappan
Don Chakkappan

Reputation: 7560

You need to override onShowListener of AlertDialogue, like the following

alert.setOnShowListener(new DialogInterface.OnShowListener() {
            @Override
            public void onShow(DialogInterface dialog) {
                Button button = alert.getButton(AlertDialog.BUTTON_POSITIVE);
                button.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View view) {

                    // Your implementation code for show next Dialogue
                    }
                });
            }
});

Do nothing in onClick of Alert Dialogue's positive button

Upvotes: 2

Related Questions