这个问题在这里已经有了答案:
How to disable AutoCompleteTextView's drop-down from showing up?
(18 个回答)
4年前关闭。
我想根据我的情况使自动完成 TextView 可编辑或不可编辑。
我将自动完成 TextView 设为可编辑
constituency.setEnabled(true);
constituency.setInputType(InputType.TYPE_CLASS_TEXT);
constituency.setClickable(true);
但它不起作用。
谁能帮帮我吗?
最佳答案
禁用 EditText
(是否自动完成)使用 editText.setInputType(0)
.在这个 post 中查看我的答案.
重新启用 EditText
在禁用之前查询输入类型的值,将其保存在变量中,例如 int safe = editText.getInputType()
并将变量放回原处,如下所示:editText.setInputType(safe)
.为了重新获得焦点,添加 editText.clearFocus()
和 editText.requestFocus()
.
关于android - 如何使自动完成 TextView 可编辑或不可编辑?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48185355/