单击EditText时如何禁用键盘? [英] How to disable the keyboard when I click on EditText?
本文介绍了单击EditText时如何禁用键盘?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
您好,我想做下一件事情:当我单击EditText时,我想隐藏键盘但看到光标.我尝试这样做:
Hello I would like to do the next thing : when I click on an EditText I would like to hide the keyboard but seeing the cursor. I tried to do this :
editText_test!!.setCursorVisible(false);
editText_test!!.setFocusableInTouchMode(false);
editText_test!!.setFocusable(true);
很明显,我没有看到键盘,但是无法单击EditText.我怎样才能做到这一点 ?确切地说,我正在使用Kotlin.
Obviously I don't see the keyboard but I can't click on my EditText. How can I do this ? To be precise I am using Kotlin.
谢谢!
推荐答案
如果您的最低 API> = 21 :
editText_test!!.showSoftInputOnFocus = false
要处理不同的版本:
if (Build.VERSION.SDK_INT >= 21) {
editText_test!!.showSoftInputOnFocus = false
} else if (Build.VERSION.SDK_INT >= 11) {
editText_test!!.setRawInputType(InputType.TYPE_CLASS_TEXT)
editText_test!!.setTextIsSelectable(true)
} else {
editText_test!!.setRawInputType(InputType.TYPE_NULL)
editText_test!!.isFocusable = true
}
这篇关于单击EditText时如何禁用键盘?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文