【发布时间】:2016-12-12 02:49:12
【问题描述】:
我正在使用 jackson 从 json 创建对象,我想在
expandableListView.
json 看起来像这样:
[
{
"name": "Pete",
"profile_img": "img001",
"relations": {
"is_working_with": [],
"is_in_course_with": [
{
"profile_img": "img002",
"name": "Jack"
}
],
"is_friends_with": [
{
"profile_img": "img003",
"name": "Stacey"
},
{
"profile_img": "img002",
"name": "Jack"
}
]
}
},
{
"name": "Jack",
"profile_img": "img002",
"relations": {
"is_working_with": [{
"profile_img": "img003",
"name": "Stacey"
}],
"is_in_course_with": [
{
"profile_img": "img001",
"name": "Pete"
}
],
"is_friends_with": [
{
"profile_img": "img003",
"name": "Stacey"
},
{
"profile_img": "img001",
"name": "Pete"
}
]
}
}
]
我的 java 类是:
public class Student {
@JsonProperty("name")
String name;
@JsonProperty("profile_img")
String profileImg;
@JsonProperty("relations")
Relations relations;
//Constructors
//Setter, Getter
}
public class Relations {
@JsonProperty("is_working_with")
List<IsWorkingWith> isWorkingWith;
@JsonProperty("is_friends_with")
List<IsFriendsWith> isFriendsWith;
@JsonProperty("is_in_course_with")
List<IsInCourseWith> isInCourseWith;
//Constructors
//Setter, Getter
}
public class IsWorkingWith {
@JsonProperty("name")
String name;
@JsonProperty("profile_img")
String profileImg;
}
public class IsFriendsWith {
@JsonProperty("name")
String name;
@JsonProperty("profile_img")
String profileImg;
}
public class IsInCourseWith {
@JsonProperty("name")
String name;
@JsonProperty("profile_img")
String profileImg;
}
我试图扩展 BaseExpandableListAdapter 并且我让它适用于组视图,但是我如何指定我的 Student 对象的哪个属性代表列表视图中的子项。
基本上我希望它看起来像这样:
我应该如何在子视图中生成项目?
【问题讨论】:
标签: java android json listview expandablelistview