来自 2 个表的 ListView
我有 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我是这样认为的:
首先,为每个表创建一个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.