0

I have an edit text. How can I make it non editable from the code. By giving the tag android:editable we can do in the layout.. But I need to do it in the code...Pls Help

dakshbhatt21
  • 3,488
  • 3
  • 30
  • 38
jennifer
  • 7,917
  • 22
  • 68
  • 96

4 Answers4

4

I believe it is as simple as

editText.setEnabled(false);
user432209
  • 19,617
  • 10
  • 54
  • 74
2

Refer EDITTEXT

        edt.setClickable(false);
    edt.setFocusable(false);


      ***Layout***

<EditText android:id="@+id/edt"
        android:layout_width="200px" android:layout_height="wrap_content"
        android:text="" android:textSize="18sp"  android:maxLength="15">
    </EditText>
Community
  • 1
  • 1
jennifer
  • 7,917
  • 22
  • 68
  • 96
1

If you didnt find yet an answer, i have found this in the net:

http://code.google.com/p/android/issues/detail?id=2854

user229044
  • 222,134
  • 40
  • 319
  • 330
peet
  • 11
  • 1
1

I am using for this problem, this solution:

valueText.setEnabled(false);
valueText.setClickable(false);
valueText.setFocusable(false);

//Just for better text vision
valueText.setTextColor(Color.WHITE);
DariusK
  • 11
  • 1