Override dialog onBackPressed()?

后端 未结 5 800
醉梦人生
醉梦人生 2020-12-16 09:51

How would I override a Dialog\'s onBackPressed to close the dialog as well as calling finish() on the Activity it is loca

5条回答
  •  轮回少年
    2020-12-16 10:50

    in my case i use DialogFragment, which is still a dialog.. so i overriden onCancel() in my dialog, and it reacts like onBackPressed() of the Activity everytime i click the back button when dialog is shown.

    @Override
    public void onCancel(DialogInterface dialog) 
    {
        super.onCancel(dialog);
        Log.i("RecDialog.onCancel()", "onCancel");
    }
    

    hope i helped.

提交回复
热议问题