Hi I\'m making custom dialer so I create my own input pad.
The problem is how do I disable the EditText but still allow cut/copy/paste?
Had a similar need due to my custom inline "fake" input which was still visible as the os soft keypad was appearing after focus moved to an edit text. Solution was to make the edit text hide soft input until the previous custom input widget had finished its edit lifecycle.
Used @Bruce's answer for inspiration, also saw a few related posts which I'll attach at end. Solution I found worked was:
fun setInputType(inputType: Int) {
getEditText().setRawInputType(inputType)
if (inputType == InputType.TYPE_NULL) {
getEditText().setTextIsSelectable(true)
getEditText().isCursorVisible = true
}
}
had to use setRawInputType()
instead as multiline text input was not respected when setting from InputType.TYPE_NULL
back to InputType.TYPE_TEXT_FLAG_MULTI_LINE
.
Seems there are users reporting issues relating to calling setInputType(InputType.TYPE_NULL)
. see:
https://issuetracker.google.com/issues/36907992
other useful related posts:
How to make EditText not editable through XML in Android?
EditText non editable