Android 4.0 EditText cursor is always invisible for editable=false

5k views Asked by At

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.

3

There are 3 answers

1
Maurycy On BEST ANSWER

Please Try

 android:clickable="false"
2
josephus On

Set android:focusable=false in your EditText.

0
Kamil Seweryn On

I had similar problem. Try using:

editText.setRawInputType(InputType.TYPE_CLASS_TEXT);
editText.setTextIsSelectable(true);

it worked for me. For more details see http://code.google.com/p/android/issues/detail?id=27609