tags:

views:

53

answers:

4

Can anyone tell me how to make an EditText not editable via XML? I tried setting android:editable to false, but (1) it is deprecated and (2) it didn't work.

A: 

The developer doc page indicates that the proper substitute (since you are correct - editable is deprecated) is to use android:inputType instead. Specifically:

android:inputType="none"

Have you tried that?

eldarerathis
Yes. No joy. :(
Fran Fitzpatrick
A: 

There is the option of using InputFilters. Please see the accepted answer in this link

kiki
A: 

They made "editable" deprecated but didn't provide a working corresponding one in inputType.

By the way, does inputType="none" has any effect? Using it or not does not make any difference as far as I see.

For example, the default editText is said to be single line. But you have to select an inputType for it to be single line. And if you select "none", it is still multiline.

Tim
A: 

Hi, What sdk are you using? I'm running android2.1 and set:

android:editable="false"

CAN work.

And I also tried in android2.2, it can work too.

This is my xml slice:

<EditText
        android:id="@+id/edit_question"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:editable="false"
        android:maxLines="4"
        />   
herbertD