Android makes AlertDialog click OK, and androidalertdialog
In alertDialog of Android, use the built-in button and click OK or cancel to close the dialog box. However, we sometimes want to click "OK" to find that there is a blank option, and we will prompt him to fill it out completely. At this time, the dialog box will not be closed. Of course there are many solutions. For example, a single activity is used as a dialog. Or custom view. use the Custom button. do not use the built-in button. however, sometimes our dialog view is very simple. At this time, we continue to use the built-in button. what should we do at this time. Java reflection technology that can be used. Where the button does not need to be closed:
Try {Field field = dialog. getClass (). getSuperclass (). getDeclaredField ("mShowing"); field. setAccessible (true); // set the mShowing variable to false, indicating that the field is closed in the dialog box. set (dialog, false); dialog. dismiss ();} catch (Exception e) {e. printStackTrace ();}
Where you need to disable the service:
Try {Field field = dialog. getClass (). getSuperclass (). getDeclaredField ("mShowing"); field. setAccessible (true); // set the mShowing variable to false, indicating that the field is closed in the dialog box. set (dialog, true); dialog. dismiss ();} catch (Exception e) {e. printStackTrace ();}
The Field package here is java. lang. reflect. Field
Specific details can refer to this article: http://blog.csdn.net/notonlyforshe/article/details/7955323