Android CheckBox使密码可见/隐藏

CheckBox cbx_pwd_visi;//CheckBox
EditText edt_pwd;//Password input

//CheckBox事件监听
cbx_pwd_visi.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
    @Override
    public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
        if (isChecked) {
            edt_pwd.setTransformationMethod(HideReturnsTransformationMethod.getInstance());//选中CheckBox,显示密码
        } else {
            edt_pwd.setTransformationMethod(PasswordTransformationMethod.getInstance());//隐藏密码
        }
    }
});


你可能感兴趣的:(Android)