禁用 Edittext 后启用它

But*_*fly 2 android android-edittext

OnButtonClick 侦听器 我想禁用 EditText 进行编辑,然后再次打开它。

在下面两行中,我禁用了 EditText

 editTextWight.setEnabled(false);
 editTextWight.setFocusable(false);
Run Code Online (Sandbox Code Playgroud)

但是当我试图把它转回来时失败了。键盘打不开。

editTextWight.setFocusable(true);
editTextWight.setFocusableInTouchMode(true);
editTextWight.setClickable(true);
editTextWight.setEnabled(true);
Run Code Online (Sandbox Code Playgroud)

请帮我启用EditText。

Een*_*ble 6

您可以尝试适用于我的项目代码的这两行:

editTextWight.setFocusable(true);
editTextWight.setFocusableInTouchMode(true);
Run Code Online (Sandbox Code Playgroud)

例如,我这样做afterTextChanged()是因为我必须先禁用它,EditText然后再启用它!

因此,只需使用上面的两个方法调用而不是所有四个方法来尝试它。

祝你好运,让我知道它是否有效!