android - 禁用后启用 Edittext

标签 android android-edittext

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

下面两行我禁用了 EditText

 editTextWight.setEnabled(false);
 editTextWight.setFocusable(false);

但是当我尝试将其转回时却失败了。键盘打不开。

editTextWight.setFocusable(true);
editTextWight.setFocusableInTouchMode(true);
editTextWight.setClickable(true);
editTextWight.setEnabled(true);

请帮助我启用 EditText。

最佳答案

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

editTextWight.setFocusable(true);
editTextWight.setFocusableInTouchMode(true);

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

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

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

关于android - 禁用后启用 Edittext,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39685945/

相关文章:

android - 恢复输入的编辑文本值

java - TextInputEditText 不适用于 Android 5.1

c# - 安卓/C# : Detect that NestedScrollView reached the bottom

android - 房间持久性库 : Cannot resolve symbol Room

android - 如何使用 BroadcastReceiver 检测蓝牙状态

java.lang.IllegalStateException : attempt to re-open an already-closed object: SQLiteQuery 错误

java - android 解析查询参数时转义编码

java - 如何使编辑文本可滚动并包含在另一个 ScrollView 中?

java - 安卓工作室 : ExpandableListView and EditText

android - 在android中打开 Activity 时如何防止键盘打开?