How to set editable true/false EditText in Android programmatically?

前端 未结 12 1189
予麋鹿
予麋鹿 2020-12-09 02:04

We can set editable property of EditText in XML layout but not programatically, but there is no setEditable() method!

If EditText

12条回答
  •  粉色の甜心
    2020-12-09 02:35

    This may help:

    if (cbProhibitEditPW.isChecked()) { // disable editing password
           editTextPassword.setFocusable(false);
           editTextPassword.setFocusableInTouchMode(false); // user touches widget on phone with touch screen
           editTextPassword.setClickable(false); // user navigates with wheel and selects widget
           isProhibitEditPassword= true;
    } else { // enable editing of password
           editTextPassword.setFocusable(true);
           editTextPassword.setFocusableInTouchMode(true);
           editTextPassword.setClickable(true);
           isProhibitEditPassword= false;
    }
    

提交回复
热议问题