How to make EditText that cannot be editted? [duplicate]
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.
editText.setFocusable(false);
editText.setClickable(false);
the two property which turn EditText to non focusable and unclickable which leads to a non editable Edittext
Make EditText Read only.
Like this:
android:enabled="false"
Or from code:
edittext.setEnabled(false)
or edittext.setFocusable(false)
or edittext.setFocusableinTouchMode(false)
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) : "";
}
}
});
try like this
android:editable="false"
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"
>
hi if you use edit text so u give this property in edit text
android:hint="write any thing"
, but dont use Android:text=""
精彩评论