I am trying to make the editText that shows the text but not as editable type. I cant use textview there because i am using same component for entering the values. How to achieve it? Any help is really appreciated and thanks in advance.
Asked
Active
Viewed 2.1k times
6
-
See this answer: http://stackoverflow.com/questions/660151/how-to-replicate-androideditable-false-in-code – TotoroTotoro Sep 20 '11 at 04:30
6 Answers
21
editText.setFocusable(false);
editText.setClickable(false);
the two property which turn EditText to non focusable and unclickable which leads to a non editable Edittext

Andro Selva
- 53,910
- 52
- 193
- 240

Mohammed Azharuddin Shaikh
- 41,633
- 14
- 96
- 115
-
-
How to do this for buttons? This code ot working for buttons...? – Pattabi Raman Sep 20 '11 at 04:40
-
-
If that button contains popup method such as showDialog(0) ? i.e date and time picker, this code which you gave wont work ah? – Pattabi Raman Sep 20 '11 at 04:45
-
-
3ya.. I have commented the functionality and your coding works... For editText, Long clicking the edittext is making to paste the clipboard contents. Can i give editText.setLongClickable(false); ? – Pattabi Raman Sep 20 '11 at 04:55
-
5
Make EditText Read only.
Like this:
android:enabled="false"
Or from code:
edittext.setEnabled(false)
or edittext.setFocusable(false)
or edittext.setFocusableinTouchMode(false)

KV Prajapati
- 93,659
- 19
- 148
- 186

Awais Tariq
- 7,724
- 5
- 31
- 54
3
try this....
EditText.setFilters(new InputFilter[] {new InputFilter()
{
@Override
public CharSequence filter(CharSequence source, int start,
int end, Spanned dest, int dstart, int dend)
{
return source.length() < 1 ? dest.subSequence(dstart, dend) : "";
}
}
});

Niranj Patel
- 32,980
- 10
- 97
- 133
0
Simply, open the layout file and add android:editable="false"
attribute.
<EditText
android:id="@+id/editText1"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:editable="false"
>

KV Prajapati
- 93,659
- 19
- 148
- 186
-5
hi if you use edit text so u give this property in edit text
android:hint="write any thing"
, but dont use Android:text=""

Niranj Patel
- 32,980
- 10
- 97
- 133

Rajesh Sharma
- 573
- 1
- 5
- 15