Home > Net >  How to prevent touch when clicking on the background of the Android dialog
How to prevent touch when clicking on the background of the Android dialog

Time:06-13

If we click the background of the dialog and click the back key, the dialog will not be canceled.

setCanceledOnTouchOutside(false);
setCancelable(false);

However, while the dialog is not canceled, there is a phenomenon that the click in the background in the buttons and the check box are clicked.

Is there a way to solve this problem?

CodePudding user response:

just add this line in onCreate method:

this.setFinishOnTouchOutside(false);

CodePudding user response:

Remove the first line keep only dialog.setCancelable(false);

  • Related