您的位置:首页 > 其它

弹出一个密码对话框,可以显示和隐藏密码

2014-06-10 13:01 357 查看
private String strPsd = null;
private EditText edtPsd = null;
private CheckBox check = null;

// 弹出输入Wifi密码框
public String showPasswordDialog(int position) {

LayoutInflater inflater = getLayoutInflater();
View layout = inflater.inflate(R.layout.check_psd,
(ViewGroup) findViewById(R.id.check_layout));
edtPsd = (EditText) layout.findViewById(R.id.editText1_check);
check = (CheckBox) layout.findViewById(R.id.checkBox1_check);
check.setTextColor(Color.WHITE);
new AlertDialog.Builder(this)
.setView(layout)
.setMessage(R.string.inputpsd)
.setNegativeButton(R.string.cancel,
new DialogInterface.OnClickListener() {

public void onClick(DialogInterface dialog,
int which) {
}
})
.setPositiveButton(R.string.ok,
new DialogInterface.OnClickListener() {

public void onClick(DialogInterface dialog,
int which) {

}
}).show();

check.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton arg0, boolean arg1) {
// TODO Auto-generated method stub
if(check.isChecked()){
edtPsd.setInputType(InputType.TYPE_TEXT_VARIATION_PASSWORD);
}else{
edtPsd.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);
}
}
});
return strPsd;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  对话框 dialog
相关文章推荐