样式如下所示:
布局:
layout
dialog_set_pwd.xml
<&#63;xml version="." encoding="utf-"&#63;>
状态选择器:
drawable
btn_blue_selector.xml
<&#63;xml version="." encoding="utf-"&#63;>
btn_white_selector.xml
<&#63;xml version="." encoding="utf-"&#63;>
引用值
values
colors.xml
<&#63;xml version="." encoding="utf-"&#63;># #a #fff #f #BDEE #CAD #FD #f
代码:
private void showSetPwdDialog() { AlertDialog.Builder builder = new AlertDialog.Builder(this); View view = View.inflate(this, R.layout.dialog_set_pwd, null); Button btnOk = (Button) view.findViewById(R.id.btn_ok); Button btnCancel = (Button) view.findViewById(R.id.btn_cancel); final EditText etPwd = (EditText) view.findViewById(R.id.et_pwd); final EditText etPwdCOnfirm= (EditText) view .findViewById(R.id.et_pwd_confirm); builder.setView(view);//将当前布局对象设置给dialog final AlertDialog dialog = builder.create(); btnOk.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { String pwd = etPwd.getText().toString().trim(); String pwdCOnfirm= etPwdConfirm.getText().toString().trim(); if (TextUtils.isEmpty(pwd) || TextUtils.isEmpty(pwdConfirm)) { ToastUtils.showToast(getApplicationContext(), "输入内容不能为空!"); } else { if (pwd.equals(pwdConfirm)) { System.out.println("登录成功!"); //将密码保存在本地sp PrefUtils.putString(getApplicationContext(), GlobalConstants.PREF_PASSWORD, MDUtils.getMd(pwd)); dialog.dismiss(); enterLostAndFindPage(); } else { ToastUtils.showToast(getApplicationContext(), "两次密码不一致!"); } } } }); btnCancel.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { dialog.dismiss(); } }); dialog.show(); }
有关Android 自定义对话框 showSetPwdDialog,小编就给大家介绍这么多,希望对大家有所帮助!