来自 2 个表的 ListView

发布于 2024-12-28 10:58:21 字数 133 浏览 2 评论 0原文

我有 2 张桌子。 在第一个表中,我有新闻(例如:2 个字段“id”和“text”)。 在第二个表中,我有附加到新闻的图像(例如:“id”、“new_id”、“src”)。

一篇新闻有不止一张图片。如何用这样的数据填充ListView?

I have 2 tables.
In the first table I have news (for example: 2 fields 'id' and 'text').
In the second table I have images, that attached to news (for example: 'id', 'new_id', 'src').

There are more than one image for one news. How can fill ListView with such data?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

硬不硬你别怂 2025-01-04 10:58:21

我是这样认为的:
首先,为每个表创建一个DTO(数据传输对象);
然后,创建代表列表单元格的布局。
您需要创建一个自定义适配器,具体操作方法如下 http ://www.vogella.de/articles/AndroidListView/article.html#ownadapter
最后一件事是从数据库中提取数据并将其传递给适配器。

此链接http://www.vogella.de/articles/AndroidListView/article.html 以清晰且更详细的方式解释了我所说的内容。

锄头这有帮助。

this is how I think of it:
first of all, create a DTO (Data transfer object) for each table;
then, create the layout that represents the list's cell.
you'll need to create a custom adapter, and here is how you can do it http://www.vogella.de/articles/AndroidListView/article.html#ownadapter.
and the last thing is to extract your data from the database and pass it to your adapter.

this link http://www.vogella.de/articles/AndroidListView/article.html explains what I said in a clear way and in more details.

hoe this helps.

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