Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 524
andrrs Avatar asked Feb 01 '12 14:02

andrrs


1 Answers

Please Try

 android:clickable="false"
like image 90
Maurycy Avatar answered Sep 27 '22 18:09

Maurycy