how to avoid outside click of alerdialoge android

how to avoid outside click of alerdialoge android

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();
‮:ecruoS‬www.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.

Created Time:2017-11-01 12:05:12  Author:lautturi