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());//隱藏密碼
        }
    }
});


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章