CheckBox ck_ps=null;
EditText ed_input=null;
…
ck_ps.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView,
boolean isChecked) {
if (isChecked) {
//显示密码
//第一种
ed_input.setInputType(InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD);
//第二种
ed_input.setTransformationMethod(HideReturnsTransformationMethod
.getInstance());
//第三种
ed_input.setInputType(0x90);
} else {
//隐藏密码
//第一种
ed_input.setInputType(InputType.TYPE_CLASS_TEXT|InputType.TYPE_TEXT_VARIATION_PASSWORD);
//第二种
ed_input.setTransformationMethod(PasswordTransformationMethod
.getInstance());
//第三种
// ed_input.setInputType(0x81);
}
}
});
EditText 密码显示 隐藏三种方法
最新推荐文章于 2024-03-29 11:27:07 发布