layout having disabled edit text

你说的曾经没有我的故事 提交于 2019-12-24 19:07:36

问题


I am building one app having one list view showing list of users this, when i click on list item it will show me complete profile of clicked user this. I take EditText fields on this layout (i use the same layout to show my own profile which is editable) whose text is filled dynamically(e.g., data of clicked user is filled in this form).Since, it only show me profile of concern user & i not need any editing on user data so i disable editing on these edit text fields by calling this method on each one.

setEnabled(false)

this layout is scrollable and when i scroll this view it enable editing on these edit text field this

How i disable editing on these edit text field...???

Any suggestions please, would appreciated any pointer, sample code to do this


回答1:


You can take TextView instead of EditText as it is a label, and if you still want it to look like edit field. you can use default editfield background by setting background of textView to

@android:drawable/edit_text in xml file.




回答2:


Actually, an EditText is needed when you want to enable user to type some information. To draw the information generated by your application you should use a TextView, which by default does not give the opportunity to change text contexts. Usually, a disabled EditText misleads users, making them feel like they've done something wrong, so try to use proper views for solving common problems. Hope this helps.




回答3:


In XML of editText write android:editable="false".



来源:https://stackoverflow.com/questions/8725107/layout-having-disabled-edit-text

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