Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make an EditText selectable but not editable on Android Ice Cream Sandwich?

Tags:

I have a ListView in Activity, and in each item , I insert an EditText for show my text. I need drag the handle to select text & copy the text, but can not edit text. On Android ICS, How can I do this?

like image 917
Limp Avatar asked May 11 '12 01:05

Limp


People also ask

How do you make EditText not editable and clickable?

For the above requirement the solution in XML is android:editable="false" but I want to use this in Java. et. setKeyListener(null); It makes the EditText not EDITABLE but at the same time it makes it non clickable as well.

How do I make text not editable on android?

android:editable="false" should work, but it is deprecated, you should be using android:inputType="none" instead. Alternatively, if you want to do it in the code you could do this : EditText mEdit = (EditText) findViewById(R.

How do you make EditText read only?

The most reliable way to do this is using UI. setReadOnly(myEditText, true) from this library. There are a few properties that have to be set, which you can check out in the source code.


1 Answers

text.setTextIsSelectable(true) requires API 11. For those using lower API's: In xml use:

android:inputType="none" android:textIsSelectable="true" 

This will make your EditText uneditable but selectable.

like image 128
Frozen Crayon Avatar answered Sep 19 '22 01:09

Frozen Crayon