1. Layout implementation:
<?xml version= "1.0" encoding= "Utf-8"? ><linearlayout xmlns:android= "http://schemas.android.com/apk/res/ Android "Android:layout_width=" Match_parent "android:layout_height=" match_parent "android:gravity=" Center_horizon Tal "android:orientation=" vertical "> <edittext android:id=" @+id/factrstdialogpsw "android:layout _width= "Match_parent" android:layout_height= "Wrap_content" android:password= "true" Android:singleline = "true"/> <linearlayout android:layout_width= "match_parent" android:layout_height= "Wrap_content" android:orientation= "Horizontal" android:layout_weight= "2" > <button android:id= "@+id/f Actrstdialogcancel "android:layout_width=" wrap_content "android:layout_height=" Wrap_content " Android:layout_gravity= "Center_horizontal" android:text= "@string/cancel" android:layout_weight= " 1 "/> <button Android:id= "@+id/factrstdialogcertain" android:layout_width= "Wrap_content" android:layout_height= " Wrap_content "android:layout_gravity=" Center_horizontal "android:text=" @string/user_dict_settings_ad D_dialog_confirm "android:layout_weight=" 1 "/></linearlayout></linearlayout>
2. Code implementation:
Import Android.app.dialog;import android.content.context;import Android.os.bundle;import Android.view.View;import Android.widget.button;import Android.widget.edittext;import Android.widget.toast;import Com.mediatek.common.featureoption.FeatureOption; public class Masterclearconfirm extends Fragment {//cbk.addprivate Dialog mfactrstpwscheckdialog;private Button Cancelbutton;private Button okbutton;private EditText pswedit;//cbk.add Private Button.onclicklistener Mfinalclicklistener = new Button.onclicklistener () {public void OnClick (View v) {if (Utils.ismonkeyrun Ning ()) {return; }///m:for CT feature resetphone with Meraseinternaldata:data | App | Media//cbk.add//mext.onresetphone (getactivity (), Meraseinternaldata, Merasesdcard); Createfactoryresetpwddialo g ();//cbk.add}};//cbk.add private void Createfactoryresetpwddialog () {if (Mfactrstpwscheckdialog = = null) { Mfactrstpwscheckdialog = new Dialog (geTactivity ());//mfactrstpwscheckdialog.requestwindowfeature (Window.feature_no_title); Mfactrstpwscheckdialog.setcontentview (R.layout.factory_rst_pwd_dialog); Mfactrstpwscheckdialog.settitle ("please Input password: ");p Swedit = (EditText) Mfactrstpwscheckdialog.findviewbyid (R.ID.FACTRSTDIALOGPSW); CancelButton = ( button) Mfactrstpwscheckdialog.findviewbyid (r.id.factrstdialogcancel); okbutton = (Button) Mfactrstpwscheckdialog.findviewbyid (R.id.factrstdialogcertain); Cancelbutton.setonclicklistener (new View.onclicklistener () {@Overridepublic void OnClick (View source) {Mfactrstpwscheckdialog.dismiss ();//finish ();}); O Kbutton.setonclicklistener (New View.onclicklistener () {@Overridepublic void OnClick (View source) {Onpairpassword ( Pswedit.gettext (). toString ());p swedit.settext (null);}});} if (mfactrstpwscheckdialog! = null) {mfactrstpwscheckdialog.show ();} } Private Boolean Onpairpassword (String value) {//LOG.D (TAG, "Onpairpassword () pwd value=" +value); Boolean Pwdvalid=fal Se if (value ==null) {//LOG.D(TAG, "Onpairpassword () value ==null"); Toast.maketext (Getactivity (), getString (R.STRING.SETTINGS_PWD_EMPTY_STR), Toast.length_short). Show (); return false ;} if (Value.length () <=0) {//log.d (TAG, "Onpairpassword () value ==null"); Toast.maketext (Getactivity (), getString (R.STRING.SETTINGS_PWD_EMPTY_STR), Toast.length_short). Show (); return false ;} String def_pwd_value =getstring (r.string.settings_pwd_def);//if (Value.length ()!=6 | | isnumeric (value) ==false) {if ( Value.length () < Def_pwd_value.length ()) {//add the item into the Locked LIST.//LOG.D (TAG, "Onpairpassword () value ==va Lid "); Toast.maketext (Getactivity (), getString (R.STRING.SETTINGS_PWD_WRONG_STR), Toast.length_short). Show (); return false ;} LOG.D (TAG, "onpairpassword () pwd_length =" +value.length ()); if (Value.equals (Def_pwd_value)) {//add the item into the Locked list.//log.d (TAG, "Onpairpassword () mpref.contains (pwd_pref_name) ==true");//no Store the PWD Activitymfactrstpwscheckdialog.dismiss ();//finish (); Mext.onresetphone (LGTivity (), Meraseinternaldata, Merasesdcard); return true;} Toast.maketext (Getactivity (), getString (R.STRING.SETTINGS_PWD_WRONG_STR), Toast.length_short). Show (); return false ; }//cbk.add}
dialog implementation mechanism of Android with password input interface