Android:如何将类嵌入另一个 xml 的文本视图中?

发布于 2024-10-03 12:22:29 字数 232 浏览 1 评论 0原文

这是我的布局:

<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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

ま柒月 2024-10-10 12:22:29

您不能将 TextView 小部件放入布局 XML 文件中的 ListView 内。另外,您不要在 TextView 中嵌入其他小部件。

要将内容放入 ListView 中,您需要使用 ListAdapter,例如 ArrayAdapterCursorAdapter,具体取决于您的数据来自哪里。

您可能希望查看ListView教程。

You do not put TextView widgets inside of a ListView 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 a ListAdapter, such as ArrayAdapter or CursorAdapter, depending on where your data is coming from.

You may wish to review the ListView tutorial.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文