6

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.

Pattabi Raman
  • 5,814
  • 10
  • 39
  • 60

6 Answers6

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
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
1

try like this

android:editable="false"
ilango j
  • 5,967
  • 2
  • 28
  • 25
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