layout having disabled edit text

2019-09-08 06:34发布

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

3条回答
爷、活的狠高调
2楼-- · 2019-09-08 06:44

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.

查看更多
女痞
3楼-- · 2019-09-08 06:46

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

查看更多
爷的心禁止访问
4楼-- · 2019-09-08 06:57

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.

查看更多
登录 后发表回答