I'm using the Groupie library for showing expandable items and my issue is that instead of the items retrieved through an api call being shown under each of their parent expandable header, they're all shown together under the last item on the list.
I would like to have this:
I have this instead:
This is my code
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)))
}
}
})
}
It looks like you missed to use Section.setHeader. So you will need to create one header instance WorkoutItem("Workout ${(w.workoutId)}"
for each w
collection item and then pass this instance into ExpandableGroup
constructor and Section.setHeader