How do I create an expandable list view in android from a List of Objects?

user3016349 picture user3016349 · Mar 25, 2014 · Viewed 15.3k times · Source

I have a list of objects in android. I want to iterate through the list and create an expandable list view, with one entry per object. I already have the ExpandableListView created in the xml file. So i Know I start with:

ExpandableListView results = ((ExpandableListView)rootView.findViewById(R.id.results));

I want to go through the list of Objects and create a Parent for each object, and each Child will be an instance variable of the main Object.

for instance:

Parent = Object.Title
  Child1 = Object.Taste
  Child2 = Object.smell
Parent1 = Object1.Title
  Child1 = Object1.Taste
  Child2 = Object1.smell

Answer

maddy d picture maddy d · Mar 25, 2014

you need to create adapter which extends BaseExpandableListAdapter it will manage child view and parent view . see this for details.