0

I have an Dialog (not an AlertDialog) which should only be dismissed when user press a button. But in my case, the dialog dismiss also when user press beside the dialog. How can i avoid that. Thnx for help!

dan
  • 873
  • 8
  • 11

3 Answers3

0

setCanceledOnTouchOutside(boolean cancel) or setCancelable(boolean flag)

These are the methods that you can use to prevent Dialog from being dismissed

Digvesh
  • 9
  • 2
0

Use

dialog.setCanceledOnTouchOutside(false);

where dialog is your Dialog variable

Dialog docs

codeMagic
  • 44,549
  • 13
  • 77
  • 93
0

Set the cancelable state to false using this: '.setCalcelable(false)'

So your dialog code would look something like this...

Dialog mDialog = new Dialog(this); mDialog.setCancelable(false);

Pkmmte
  • 2,822
  • 1
  • 31
  • 41