Reputation: 15
Trying to create expandable list view in android. I would like each group to expand to a pre-set XML layout file. For example.
Group A { when expanded displays XML file A: buttons, seekbar, spinner and etc }
Group B { when expanded displays XML file B: buttons, seekbar, spinner and etc }
Group C { when expanded displays XML file C: buttons, seekbar, spinner and etc }
Group D { when expanded displays XML file D: buttons, seekbar, spinner and etc }
Group E { when expanded displays XML file E: buttons, seekbar, spinner and etc }
Creating the XML file is simple. How can I display the XML file inside desired group?
Upvotes: 1
Views: 2606
Reputation: 2406
If you're using a BaseExpandableListAdapter
, you can override the methods getChildTypeCount()
and getChildType()
. Then you can inflate your matching layout in getChildView()
, the parameter convertView
will then always be of the correct type.
In your example, getChildTypeCount()
would return 5 and getChildType()
could simply return the groupId.
Upvotes: 3
Reputation: 1778
Unfortunately you may inflate only one xml layout file that would describe your listView. Eventhough you might insert logics that would determine what kind of element is it and programmatically change it's view in getView() method of the adapter.
Upvotes: 1