Reputation: 41
I want to do an alert dialog
in an Android app. When I put the setPositiveButton
and setNegativeButton
all is right but when I click on the background, the alert dialog
disappears and this functionality I don't want it.
I need that the user only can choose two possibilities and when the user touch the background, the alert dialog doesn't disappear.
Upvotes: 0
Views: 524
Reputation: 795
To prevent dialog box from getting dismissed on back key pressed use this
dialog.setCancelable(false);
And to prevent outside touch use this
dialog.setCanceledOnTouchOutside(false);
Upvotes: 1
Reputation: 12745
You want to make sure your AlertDialog is not cancelable.
alertDialogBuilder.setCancelable(false);
Check the documentation here.
Upvotes: 0