Sometimes I may not need to click on the button to do some testing, but do not want to close the dialog box (the system by default click on any button to close the dialog box), the process is as follows: Add the following code under the Click event:
Java code
- Try
- {
- Field field = Dialog.getclass ()
- . Getsuperclass (). Getdeclaredfield (
- "Mshowing");
- Field.setaccessible (true);
- Set the mshowing variable to false to indicate that the dialog box is closed
- Field.set (dialog, false);
- Dialog.dismiss ();
- }
- catch (Exception e)
- {
- }
Add the above code to the click event code of which button, which will no longer close the dialog box. If you want to close the dialog box, simply set Mshowing to True. Note that setting the mshowing variable in one of the buttons also affects the function of the Close dialog box for the other button, so you need to set the value of the mshowing variable in each button's Click event.
android--Clicking on the dialog button does not close the dialog box