This article then implements the "Confirm password" function, that is, the user has previously set the password, now only need to enter a confirmation password
Layout files and "Android phone defender--Set Password dialog" in the layout is basically similar, all copy, change a little bit of detail will be done:
<?xml version= "1.0" encoding= "Utf-8"?> <linearlayout "xmlns:android="
Schemas.android.com/apk/res/android "android:layout_width=" match_parent "android:layout_height=" Match_parent " android:orientation= "vertical" > <textview style= "@style/titlestyle" android:background= "#f00" android:text= " Confirm Password "/> <edittext android:id=" @+id/et_confirm_psd android:layout_width= "Match_parent" android:layout_height = "Wrap_content" android:hint= "Confirm password"/> <linearlayout android:layout_width= "Match_parent" Android:layout_heigh t= "Wrap_content" > <button android:id= "@+id/bt_submit" android:layout_width= "0DP" android:layout_height= "wrap _content "android:layout_weight=" 1 "android:text=" confirmation "/> <button android:id=" @+id/bt_cancel "Android:layout_wi Dth= "0DP" android:layout_height= "Wrap_content" android:layout_weight= "1" android:text= "Cancel"/> </LinearLayout&
Gt </LinearLayout>
Code logic is basically similar, and simple to modify
/** * Confirm Password dialog box */private void Showconfirmpsddialog () {//need to define the display style of dialog box, so call Dialog.setview (view);
Builder Builder = new Builder (this);
Final Alertdialog Dialog = Builder.create ();
Final View view = Inflate (this, r.layout.dialog_confirm_psd, null);
Let the dialog box display a dialog box with its own definition of the interface effect 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 (New Onclicklistener () {@Override public void OnClick (View v) {EditText et_confirm_psd =
(EditText) View.findviewbyid (R.ID.ET_CONFIRM_PSD);
String confirmpsd = Et_confirm_psd.gettext (). toString ();
String psd = sputil.getstring (Getapplicationcontext (), CONSTANTVALUE.MOBILE_SAFE_PSD, ""); if (! Textutils.isempty (CONFIRMPSD)) {//Enter user mobile phone anti-theft module if (psd.equals (CONFIRMPSD)) {Intent Intent = new Intent (getapplicationc
Ontext (), testactivity.class);
StartActivity (Intent);
Jump to the new interface after the need to hide the dialog box Dialog.dismiss (); else {toastutil.show (Getapplicationcontext (), "Input password error");
}else{///Prompt user password input is empty toastutil.show (Getapplicationcontext (), "Please enter password");
}
}
});
Bt_cancel.setonclicklistener (New Onclicklistener () {@Override public void OnClick (view view) {Dialog.dismiss ();
}
});
}
The above is the entire content of this article, I hope to help you learn, but also hope that we support the cloud habitat community.