layout having disabled edit text

2019-09-08 06:24发布

问题:

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