Show the password with EditText

前端 未结 12 915
旧时难觅i
旧时难觅i 2021-01-30 22:04

I use an EditText to enter password. And a CheckBox to show password or not. Below function is the part:

public void ShowPassword() {
    if (cb.isChecked()) {
          


        
12条回答
  •  旧巷少年郎
    2021-01-30 22:47

    This will work -

    public void ShowPassword() {
        if (cb.isChecked()) {
            password.setInputType(InputType.TYPE_CLASS_TEXT);
        } else {
            password.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);
        }
    }
    

提交回复
热议问题