Search code examples
androidinputandroid-edittexttext-cursor

Android 4.0 EditText cursor is always invisible for editable=false


In my app I want an EditText that doesn't accept any input, i.e. android:editable="false" in XML layout or setKeyListener(null) in code.

I only want to add characters in a very controlled manner, and so I always add it programmatically with setText() and I don't want any virtual keyboard to show up. However, I still need a visible cursor in the EditText so that the user will know where the programmatic input will be inserted.

This was very easy to implement (android:editable="false") until Android 4.0. In 4.0, the cursor was apparently removed. I've tried android:cursorVisible="true" but it doesn't work.

Does anyone know how to both have a visible cursor and still suppress input in Android 4.0? Really grateful for any help here.


Solution

  • Please Try

     android:clickable="false"