android--Clicking on the dialog box button does not close the dialog box

Source: Internet
Author: User

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
    1. Try
    2. {
    3. Field field = Dialog.getclass ()
    4. . Getsuperclass (). Getdeclaredfield (
    5. "Mshowing");
    6. Field.setaccessible (true);
    7. Set the mshowing variable to false to indicate that the dialog box is closed
    8. Field.set (dialog, false);
    9. Dialog.dismiss ();
    10. }
    11. catch (Exception e)
    12. {
    13. }

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.