如何将页脚视图添加到ExpandableListActivity中的子列表?

Jam*_*mes 4 android listview expandablelistview

我一直在试图找出如何将孩子添加View到孩子ListExpandableListActivity,但无济于事.

我可以得到ExpandableListView并调用addFooterView()它,但这只是将新View增加到组列表中.(数据来自a Cursor).

任何建议都感激不尽.

干杯

詹姆士

Dev*_*red 14

不幸的是,没有ExpandableListView.addChildFooterView()方法,甚至没有方法ExpandableListView.addFooterView().您调用的方法是继承的ListView.addFooterView(),它只是将视图添加为整个列表中的最后一项.它没有被团体/儿童行为所覆盖.

最简单的方法可能只是在您的ExpandableListAdapter实现中构建一些内容,以便getChildrenCount()返回数据集大小+ 1,然后返回页脚视图以getChildView()获取适当的位置.此外,getChildView()还提供一个布尔参数来标记何时检索任何特定组中的最后一个子项.