User dialog is rejected when I click on it

I have a custom dialog that rejects when clicked outside of the dialog box, which I don't want. dialog.setCanceledOnTouchOutside(false); does not fix the problem. What am I doing wrong?

 dialog = new Dialog(context); dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); dialog.setCanceledOnTouchOutside(false); dialog.setContentView(R.layout.twitter_dialog); // set up edit text and other widgets dialog.getWindow().setLayout(450, 280); dialog.show(); 

EDIT: I call this dialog from another dialog that has setCanceledOnTouchOutside (true). Before invoking this dialog, the previous dialog is rejected.

+4
source share
4 answers

I managed to solve my problem using AlertDialog

0
source

you can use getDialog (). setCanceledOnTouchOutside (false);

+13
source

This work for me:

 dialog.getWindow().addFlags(WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL); 
+7
source

Please check the sample code.

 EditDialog newDialog = new EditDialog(); newDialog .setCancelable(false); ///This will prevent closing the dialog on back button press/ touch outside newDialog .show(getSupportFragmentManager(),"dialog"); 
0
source

All Articles