Sometimes I don't have to do some checking by clicking on the button. But do not want to close the dialog box (the system by default click on any button to close the dialog box), processing methods such as the following: Under the Click event to add such as the following code:
- Try
- {
- Field field = Dialog.getclass ()
- . Getsuperclass (). Getdeclaredfield (
- "Mshowing");
- Field.setaccessible (true);
- Set the mshowing variable to false. Indicates that the dialog box is closed
- Field.set (dialog, false);
- Dialog.dismiss ();
- }
- catch (Exception e)
- {
- }
Add the above code to which button's Click event code, which button can no longer close the dialog box.
Suppose you want to close the dialog box, just set mshowing to true. Note that setting the mshowing variable in a button also affects the ability to close the dialog box with a button, so you need to set the value of the mshowing variable in each button's Click event.
android--Click on the dialog box button does not close the dialog box