How to handle Back button with in the dialog?

后端 未结 8 2281
无人共我
无人共我 2020-11-30 01:02

I am developing an application that when the button is pressed, it opens a dialog with OK and Cancel buttons.

It works fine.

When the user presses the back b

8条回答
  •  無奈伤痛
    2020-11-30 01:29

    Sounds like you want to set the OnCancelListener when you create the Dialog. It looks like this:

    dialog.setOnCancelListener(new DialogInterface.OnCancelListener() {         
        @Override
        public void onCancel(DialogInterface dialog) {
            //do whatever you want the back key to do
        }
    });
    

提交回复
热议问题