就像几乎所有有登录和忘记密码的应用一样,显示和隐藏密码是不可少的
兄弟们,上代码!!!
showPwd = (CheckBox) findViewById(R.id.showPwd);
showPwd.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (isChecked) {
//如果选中,显示密码
et_new.setTransformationMethod(HideReturnsTransformationMethod.getInstance());
et_old.setTransformationMethod(HideReturnsTransformationMethod.getInstance());
} else {
//否则隐藏密码
et_new.setTransformationMethod(PasswordTransformationMethod.getInstance());
et_old.setTransformationMethod(PasswordTransformationMethod.getInstance());
}
}
});
不写注释的程序员不是一个好的CTO