博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Android 带password输入界面的Dialog实现机制
阅读量:6343 次
发布时间:2019-06-22

本文共 3479 字,大约阅读时间需要 11 分钟。

1.布局实现:

2.代码实现:

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.add	private 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.isMonkeyRunning()) {                return;            }            /// M:For CT feature resetPhone with mEraseInternalData: data | app | media 			//cbk.add            //mExt.onResetPhone(getActivity(), mEraseInternalData, mEraseSdCard);			createFactoryResetPwdDialog();				//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:");					pswEdit = (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()			{				@Override				public void onClick(View source)				{					mFactRstPwsCheckDialog.dismiss();//finish();				}			});						okButton.setOnClickListener(new View.OnClickListener()			{				@Override				public void onClick(View source)				{					onPairPassword(pswEdit.getText().toString());					pswEdit.setText(null);				}			});		}		if (mFactRstPwsCheckDialog != null) {			mFactRstPwsCheckDialog.show();		}	    }    private boolean onPairPassword(String value){			//Log.d(TAG, "onPairPassword()  pwd value=" +value);		boolean pwdvalid=false; 		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 ==valid");			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 activity			mFactRstPwsCheckDialog.dismiss();//finish();			mExt.onResetPhone(getActivity(), mEraseInternalData, mEraseSdCard);			return true;		}		Toast.makeText(getActivity(), getString(R.string.settings_pwd_wrong_str), Toast.LENGTH_SHORT).show();		return false;    }	//cbk.add	}

转载地址:http://nskla.baihongyu.com/

你可能感兴趣的文章
我的友情链接
查看>>
SaltStack源码分析之service模块
查看>>
我的友情链接
查看>>
2013-7-17学习作业练习
查看>>
利用SVN的post-commit钩子实现多项目自动同步
查看>>
医疗卫生信息化、医学资料下载
查看>>
linux用户管理实验3:usermod命令
查看>>
2款比较炫的图片左右切换,放大效果。
查看>>
nginx下日志切割的shell
查看>>
动态代理实例
查看>>
GNS3 配置Static p2p GRE over IPsec
查看>>
Linux下软件的安装与管理(四)
查看>>
Immutable集合
查看>>
百度竞价排名屏蔽插件for Chrome
查看>>
MySQL数据库水平切分的实现原理解析
查看>>
python网络编程学习笔记(7):HTML和XHTML解析(HTMLParser、BeautifulSoup)
查看>>
ctf.360.cn第二届,逆向部分writeup——第二题
查看>>
Windows Server 2012 将资源发布到 AD DS
查看>>
Redhat linux C 函数 以及一些shell命令的 man rpm
查看>>
XenServer 6.0发布
查看>>