Ich erschaffe Objekte von json mit jackson und ich möchte diese Objekte in einem expandableListView
zeigen.Wie ordne ich diese Liste von Objekten einer erweiterbaren Listenansicht zu?
Die json sieht wie folgt aus:
[
{
"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"
}
]
}
}
]
Und meine Java-Klassen sind:
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;
}
ich versuchte BaseExpandableListAdapter
zu erweitern und ich habe es für die Gruppenansichten arbeiten, aber, wie ich tun Geben Sie an, welches Attribut meines Objekts Student
die untergeordneten Elemente in der Listenansicht darstellt.
Grundsätzlich möchte ich es wie folgt aussehen:
Wie soll ich die Elemente in der untergeordneten Ansicht generieren?