Make an EditText non-editable, using enabled

How to make an EditText non-editable, using enabled

This is a 'workaround'. The proper XML to use to set an EditText to non-editable is android:inputType="none". However, there is a bug in Android code, and this does not work.

This will gray out the background of the EditText. However, the user will not be able edit the text.

1. Create an Android project, if you don't already have one.

2. Add a EditText.

3. In the main.xml file, add the below line

  <TextView
    .... //Added in API level 1
      android:enabled = "false" 
  />
 
5. Compile and run!

Related Articles
Resources:
developer.android.com/reference/android/R.attr.html#enabled
https://code.google.com/p/android/issues/detail?id=2854