Suppose you have an AlertDialog
with two buttons A and B. I have found that on some devices and some versions of android, if you touch any area of the screen around the dialog, the AlertDialog
disappears. On other devices you are forced to select either A or B, so there is no way I can allow the user to cancel the action without adding a third ('Cancel') option to the AlertDialog
. Is there any way to determine programmatically whether the third option is required?
You can control it with dialog.setCanceledOnTouchOutside(true);
For more information :
How to dismiss the dialog with click on outside of the dialog?
Dialog dialog = new Dialog(context)
dialog.setCanceledOnTouchOutside(true);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.