This article implements the logical judgment of setting the password dialog box
This article address: http://www.cnblogs.com/wuyudong/p/5940551.html, reprint please indicate the source.
First, add the Listener event code for the button
/*** Set Password dialog box*/ Private voidShowsetpsddialog () {//You need to define the display style of the dialog, so call Dialog.setview (view); Builder builder = new Builder (this); Final alertdialog dialog = builder.create (); Final View view = Inflate (This, R.LAYOUT.DIALOG_SET_PSD, null); //Let the dialog box display a dialog interface effect that you define yourself Dialog.setview (view); Dialog.show (); Button Bt_submit=(Button) view. Findviewbyid (R.id.bt_submit); Button Bt_cancel=(Button) view. Findviewbyid (R.id.bt_cancel); Bt_submit.setonclicklistener (NewOnclicklistener () {@Override Public voidOnClick (View v) {EditText et_set_psd=(EditText) view. Findviewbyid (R.ID.ET_SET_PSD); EditText ET_CONFIRM_PSD=(EditText) view. Findviewbyid (R.ID.ET_CONFIRM_PSD); String PSD=Et_set_psd.gettext (). toString (); String CONFIRMPSD=Et_confirm_psd.gettext (). toString (); if(! Textutils.isempty (PSD) &&!Textutils.isempty (CONFIRMPSD)) { //Enter the user mobile phone anti-theft module if(Psd.equals (CONFIRMPSD)) { Intent Intent = new Intent (Getapplicationcontext (), testactivity. Class); StartActivity (Intent); //go to the new interface to hide the dialog boxDialog.dismiss (); } Else{toastutil.show (Getapplicationcontext (),"Password Inconsistent"); } }Else{ //to prompt the user for password entry is emptyToastutil.show (Getapplicationcontext (), "Please enter password"); } } }); Bt_cancel.setonclicklistener (NewOnclicklistener () {@Override Public voidOnClick (view view) {Dialog.dismiss (); } }); }
Here to create a new activity:testactivity for testing, first see the effect, and then implement the specific
Public class extends Activity { @Override protectedvoid onCreate (Bundle savedinstancestate) { Super . OnCreate (savedinstancestate); New TextView (this); Textview.settext ("testactivity!" ); Setcontentview (TextView); }}
Then add the following code to the manifest file:
<android:name= "com.wuyudong.mobilesafe.activity.testActivity"></ activity>
Android phone Defender--Dialogue initial password verification process