Android:如何将类嵌入另一个 xml 的文本视图中?
这是我的布局:
<ListView>
<TextView></TextView>
</ListView
这个 xml 是 main.xml 和 main.java。我如何将 intro.xml 和 intro.java 嵌入到
感谢您的帮助。
This is my layout:
<ListView>
<TextView></TextView>
</ListView
This xml is the main.xml with main.java. How can i embed intro.xml with intro.java into the <Textview>?
thanks for your help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您不能将
TextView
小部件放入布局 XML 文件中的ListView
内。另外,您不要在 TextView 中嵌入其他小部件。要将内容放入
ListView
中,您需要使用ListAdapter
,例如ArrayAdapter
或CursorAdapter
,具体取决于您的数据来自哪里。您可能希望查看
ListView
教程。You do not put
TextView
widgets inside of aListView
in a layout XML file. Also, you do not embed other widgets inside of a TextView.To put things in a
ListView
, you need to use aListAdapter
, such asArrayAdapter
orCursorAdapter
, depending on where your data is coming from.You may wish to review the
ListView
tutorial.