Making not editable EditText component [duplicate]

夙愿已清 提交于 2019-12-11 17:17:16

问题


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


回答1:


I believe it is as simple as

editText.setEnabled(false);



回答2:


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>



回答3:


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

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




回答4:


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);


来源:https://stackoverflow.com/questions/4824676/making-not-editable-edittext-component

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!