禁用编辑文本的布局
我正在构建一个应用程序,它有一个列表视图,显示用户列表这个 ,当我单击列表项时,它将显示所单击用户的完整个人资料这个< /a>.我在此布局上使用 EditText 字段(我使用相同的布局来显示我自己的可编辑个人资料),其文本是动态填充的(例如,单击用户的数据填充在此表单中)。因为,它只显示我关注的个人资料用户&我不需要对用户数据进行任何编辑,因此我通过在每个编辑文本字段上调用此方法来禁用对这些编辑文本字段的编辑。
设置启用(假)
此布局是可滚动的,当我滚动此视图时,它可以在这些编辑文本字段上进行编辑 这
我如何禁用这些编辑文本字段上的编辑...???
请提供任何建议,将不胜感激任何指针,示例代码来执行此操作
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
实际上,当你想让用户输入一些信息时,需要一个
EditText
。要绘制应用程序生成的信息,您应该使用TextView
,默认情况下它不提供更改文本上下文的机会。通常,禁用的EditText
会误导用户,让他们觉得自己做错了什么,因此请尝试使用正确的视图来解决常见问题。希望这有帮助。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 aTextView
, which by default does not give the opportunity to change text contexts. Usually, a disabledEditText
misleads users, making them feel like they've done something wrong, so try to use proper views for solving common problems. Hope this helps.您可以使用 TextView 而不是 EditText,因为它是一个标签,并且如果您仍然希望它看起来像编辑字段。您可以通过
在 xml 文件中将 textView 的背景设置为 @android:drawable/edit_text 来使用默认的编辑字段背景。
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.
在
editText
的 XML 中写入android:editable="false"
。In XML of
editText
writeandroid:editable="false"
.