This problem has been bothering me before, my need is to click on the outside of the dialog box and press the Return Key dialog box will not disappear, press the return key is OK to solve, intercept the next return button OK.
But clicking outside is not a good solution. Before someone said modal dialog box, I looked for a while and thought it was not the effect I wanted. Popwindow, you must provide the parent view.
Look at the API again and find that setting the Setcancelable property is OK.
Such as:
Public voidShownoproject () {Builder builder=NewAlertdialog.builder (mainactivity. This). Setmessage ("You do not have a project, please add items first"). Setpositivebutton ("Go to add Item",NewOnclicklistener () {@Override Public voidOnClick (Dialoginterface Dialog,intwhich) {Dialog.dismiss (); }}). Setnegativebutton ("Off",NewOnclicklistener () {@Override Public voidOnClick (Dialoginterface Dialog,intwhich) {Dialog.dismiss (); } }); Builder.setcancelable (false); Builder.show (); }
Android makes Alertdialog.builder not click outside and press the back key to disappear