Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Create an Expandable listview with section headers in android

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?

like image 692
cavallo Avatar asked Feb 08 '13 11:02

cavallo


People also ask

How to create Expandable list view in Android?

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.

How do you get a child position in ExpandableListView?

You have to use Adapter's getChild(groupPosition, childPosition) method to retrieve the instance of child.


1 Answers

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.

like image 58
BC2 Avatar answered Oct 05 '22 23:10

BC2