Android – How to replicate android:editable=”false” in code


In the layout you can set the EditText widget to be non-editable via the android:editable attribute.

How can I do this in code? I need to make the EditText widget to be editable depending on conditions.

Best Solution


this ensure the EditText control can't be selected and focused, so it can't be edited.