Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to disable EditText in Android

How can I disable typing in an EditText field in Android?

like image 751
aj10 Avatar asked May 04 '11 06:05

aj10


People also ask

How do I turn off edit text on android?

What should I set to disable EditText? It's possible to preserve both the style of the view and the scrolling behaviour. To disable an EditText while keeping this properties, just use UI. setReadOnly(myEditText, true) from this library.

How do I turn off TextView?

Android EditText Disable Edit and Focus (read only TextView behaviour) Without Disable. If you disable EditText using setEnabled(false) , the style/color will change to light gray. To disable EditText (no focus and edit) wihout disabling it.

How do you make EditText not editable?

Make EditText non editable in Android To use this just set android:inputType="none" and it will become non editable.


2 Answers

you can use EditText.setFocusable(false) to disable editing
EditText.setFocusableInTouchMode(true) to enable editing;

like image 121
chaitanya Avatar answered Sep 28 '22 22:09

chaitanya


In code:

editText.setEnabled(false); 

Or, in XML:

android:editable="false" 
like image 21
Gabriel Negut Avatar answered Sep 28 '22 23:09

Gabriel Negut