开发者

How to make EditText that cannot be editted? [duplicate]

开发者 https://www.devze.com 2023-04-05 20:35 出处:网络
This question already has answers here: 开发者_运维问答 Make EditText ReadOnly (24 answers) Closed 8 years ago.
This question already has answers here: 开发者_运维问答 Make EditText ReadOnly (24 answers) Closed 8 years ago.

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=""

0

精彩评论

暂无评论...
验证码 换一张
取 消