Making not editable EditText component [duplicate]

2019-09-04 07:35发布

This question already has an answer here:

I have an edit text. How can I make it non editable from the code. By giving the tag android:editable we can do in the layout.. But I need to do it in the code...Pls Help

4条回答
叼着烟拽天下
2楼-- · 2019-09-04 07:59

I am using for this problem, this solution:

valueText.setEnabled(false);
valueText.setClickable(false);
valueText.setFocusable(false);

//Just for better text vision
valueText.setTextColor(Color.WHITE);
查看更多
闹够了就滚
3楼-- · 2019-09-04 08:07

I believe it is as simple as

editText.setEnabled(false);
查看更多
做自己的国王
4楼-- · 2019-09-04 08:08

If you didnt find yet an answer, i have found this in the net:

http://code.google.com/p/android/issues/detail?id=2854

查看更多
等我变得足够好
5楼-- · 2019-09-04 08:18

Refer EDITTEXT

        edt.setClickable(false);
    edt.setFocusable(false);


      ***Layout***

<EditText android:id="@+id/edt"
        android:layout_width="200px" android:layout_height="wrap_content"
        android:text="" android:textSize="18sp"  android:maxLength="15">
    </EditText>
查看更多
登录 后发表回答