Show the password with EditText

前端 未结 12 897
旧时难觅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:33

    okay:

    To show readeable text:

    setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD)
    

    To "star" the password:

    setInputType(InputType.TYPE_TEXT_VARIATION_PASSWORD)
    

    But why? The Type_Text_Variation_Password set it to stars, but why does only adding Type_Claas_Text revive the visibel password?
    I would have thought that Type_Text_Variation_VISIBLE_Password comes into play ...

提交回复
热议问题