【发布时间】:2019-06-27 14:52:09
【问题描述】:
我正在使用 Groupie 库来显示可扩展项目,我的问题是,通过 api 调用检索到的项目并没有显示在它们的每个父可扩展标题下,而是一起显示在列表。
我想要这个:
- 标题 1
- 子标题 1
- 子标题 1
- 子标题 1
- 标题 2
- 子标题 2
- 子标题 2
我有这个:
- 标题 1
- 标题 2
- 子标题 1
- 子标题 1
- 子标题 1
- 子标题 2
- 子标题 2
这是我的代码
private fun updateUICurrentExercise(getCurrentWorkoutExercise: GetCurrentWorkoutExercise?) {
adapter = GroupAdapter()
val workouts = getCurrentWorkoutExercise?.workouts
for (w in workouts!!) {
exp = ExpandableGroup(WorkoutItem("Workout ${(w.workoutId)}"), false)
getExercisesByWorkoutAPI(w.workoutId.toString())
adapter.add(exp)
}
rvWorkout.adapter = adapter
}
private fun getExercisesByWorkoutAPI(workoutId: String) {
GetExercisesByWorkoutAPI.postData(jo, object : GetExercisesByWorkoutAPI.ThisCallback {
override fun onSuccess(getExercisesByWorkout: GetExercisesByWorkout?) {
for (e in getExercisesByWorkout?.exercises!!) {
exp.add(Section(ExerciseItem(workoutId)))
}
}
})
}
【问题讨论】:
标签: android kotlin android-recyclerview expandablelistview groupie