Android disables AlertDialog and androidalertdialog.

Source: Internet
Author: User

Android disables AlertDialog and androidalertdialog.

1 AlertDialog. builder builder = new AlertDialog. builder (getActivity (); 2 builder. setTitle ("test"); 3 4 LayoutInflater inflater = getActivity (). getLayoutInflater (); 5 View view = inflater. inflate (R. layout. dialogfragment_num_input, null); 6 builder. setView (view); 7 8 builder. setPositiveButton ("OK", 9 new DialogInterface. onClickListener () {10 @ Override11 public void onClick (DialogInterface dialog, int id) {12 13 Field field = null; 14 15 try {16 // obtain the private attribute mShowing17 field = dialog in dialog through reflection. getClass (). getSuperclass (). getDeclaredField ("mShowing"); 18 field. setAccessible (true); // set this attribute to access 19} catch (Exception ex) {20 21} 22 23 String inputValue = String. valueOf (mEdit. getText (); 24 if (inputValue = null | "". equals (inputValue) {25 try {26 // set dialog to disable 27 field. set (dialog, false); 28 dialog. dismiss (); 29} catch (Exception ex) {30} 31} else {32 33 // 34 // do your own thing 35 // 36 try {37 // close 38 field. set (dialog, true); 39 dialog. dismiss (); 40} catch (Exception ex) {41} 42} 43} 44}); 45 builder. setNegativeButton ("cancel", 46 new DialogInterface. onClickListener () {47 @ Override48 public void onClick (DialogInterface dialog, int id) {49 50 Field field = null; 51 52 try {53 // obtain the private attribute mShowing54 field = dialog in dialog through reflection. getClass (). getSuperclass (). getDeclaredField ("mShowing"); 55 field. setAccessible (true); // set this attribute to access 56} catch (Exception ex) {57} 58 59 try {60 field. set (dialog, true); 61 dialog. dismiss (); 62} catch (Exception ex) {63} 64 65} 66}); 67 68 69 builder. create ();

 

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.