篇首语:本文由编程笔记#自由互联小编为大家整理,主要介绍了Android手机卫士--确认密码对话框编写相关的知识,希望对你有一定的参考价值。本文接着实现确认密码 Builder builder = ne
篇首语:本文由编程笔记#自由互联小编为大家整理,主要介绍了Android手机卫士--确认密码对话框编写相关的知识,希望对你有一定的参考价值。本文接着实现确认密码 Builder builder = new Builder(this); final AlertDialog dialog = builder.create(); final View view = inflate(this, R.layout.dialog_confirm_psd, null); //让对话框显示一个自己定义的对话框界面效果 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)){ //进入用户手机防盗模块 if(psd.equals(confirmPsd)) { Intent intent = new Intent(getApplicationContext(), testActivity.class); startActivity(intent); //跳转到新的界面以后需要去隐藏对话框 dialog.dismiss(); } else { ToastUtil.show(getApplicationContext(),"输入密码错误"); } }else{ //提示用户密码输入为空的情况 ToastUtil.show(getApplicationContext(),"请输入密码"); } } }); bt_cancel.setOnClickListener(new OnClickListener() { @Override public void onClick(View view) { dialog.dismiss(); } }); }