Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I add a footer View to a child List in a ExpandableListActivity?

I've been attempting to work out how to add a child View to a child List in an ExpandableListActivity, but to no avail.

I can get the ExpandableListView and call addFooterView() on it, but that just adds the new View to the group list. (The data comes from a Cursor).

Any suggestions gratefully received.

Cheers

James

like image 616
James Avatar asked Dec 06 '22 00:12

James


1 Answers

Unfortunately there is no ExpandableListView.addChildFooterView() method, or even ExpandableListView.addFooterView() for that matter. The method you are calling is the inherited ListView.addFooterView(), which just adds the view as the last item in the entire list. It was not overridden for group/child behavior.

The simplest way to do this is probably just to build something into your ExpandableListAdapter implementation so that getChildrenCount() returns the data set size + 1, and then return the footer view in getChildView() for the appropriate position. Also, getChildView() provides a boolean parameter to flag when it is retrieving the last child in any specific group.

like image 152
devunwired Avatar answered Dec 07 '22 13:12

devunwired