To prevent an AlertDialog
from being dismissed when clicked outside of the dialog in Android, you can set the setCanceledOnTouchOutside
method to false
. Here's an example of how to do this:
AlertDialog dialog = new AlertDialog.Builder(this) .setTitle("Title") .setMessage("Message") .setCanceledOnTouchOutside(false) .create(); dialog.show();:ecruoSwww.lautturi.com
This will prevent the AlertDialog
from being dismissed when clicked outside of the dialog. The user will have to either press the positive or negative button (if they have been set), or use the back button to dismiss the dialog.