【发布时间】:2025-12-24 08:45:11
【问题描述】:
我有一个自定义列表视图,可以在我的屏幕上显示帖子。有些帖子有 cmets,这就是为什么我需要另一个列表视图以便 cmets 可以与帖子一起显示。我正在使用 volley 并制作了一个 post 类,其中包含不同属性的 getter 和 setter 方法。我正在使用自定义列表视图适配器来显示帖子详细信息,但我也不明白如何显示 cmets。有人可以帮助我解释实现这一目标的最佳方法吗?
这是将使用的 JSON 示例:
{
id: "10",
author_id: "1",
name: "John",
picture: "uploads/image.jpg",
text: "hello this is my first post:)"
comments: [
{
comment: "Hello",
comment_id: "1",
comment_author_id: "2",
post_id: "10"
},
{
comment: "Hi",
comment_id: "2",
comment_author_id: "1",
post_id: "10"
},
]
},
{
id: "11",
author_id: "3",
name: "Jane",
picture: "uploads/image_2.jpg",
text: "hello World ! "
comments: []
},
我希望它看起来像下图,因此 cmets 会与帖子一起显示: http://i.stack.imgur.com/RfzNw.jpg
任何帮助都会很棒:)
【问题讨论】:
标签: android json listview android-listview custom-lists