In my application I have to include an expandable list view with section headers, I have succeeded doing them separately like list view with headers and expandable list view but when I have to do it both I am stuck,
I got three arraylist of data.ArrayList<String[]>
headers.ArrayList<String[]>
list.ArrayList<String[]>
child.
and I have created separate layouts for all the three. How to create this expandable list view with headers?
For Creating a custom ExpandableListView we need to create a custom class and then extends BaseExpandableListAdapter class in that class. Below is an example code of BaseExpandableListAdapter in which we create custom adapter class and then extends BaseExpandableListAdapter in that class.
You have to use Adapter's getChild(groupPosition, childPosition) method to retrieve the instance of child.
Try using the addHeaderView()
method for each of the ArrayList
of headers. This way, you can dynamically create TextViews
or any View
desired to each of the ExpandableListViews
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With