Android EditText密码显示隐藏
checkBox1.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
// TODO Auto-generated method stub
if(isChecked){
//如果选中,显示密码
editText1.setTransformationMethod(HideReturnsTransformationMethod.getInstance());
}else{
//否则隐藏密码 editText1.setTransformationMethod(PasswordTransformationMethod.getInstance());
}
}
});
当CheckBox被选中时,EditText的内容通过HideReturnsTransformationMethod显示,否则使用PasswordTransformationMethod隐藏密码。此代码段展示了如何根据用户交互动态改变EditText的密码可见性。
1789

被折叠的 条评论
为什么被折叠?



