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);
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.
Thank you !
If you have minimum API >= 21:
editText_test!!.showSoftInputOnFocus = false
To deal with different versions:
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
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With