ExpandableListView继承自ListVie,它把应用中的列表分为几组,每组又包含多个列表项,实现可展开的列表。
列表项由ExpandableListAdapter提供。
实现ExpandableAdapter的三种方式
1.扩展BaseExpandableListAdpter实现ExpandableAdapter。
2.使用SimpleExpandableListAdpater将两个List集合包装成ExpandableAdapter
3.是使用simpleCursorTreeAdapter将Cursor中的数据包装成SimpleCuroTreeAdapt
本例采用第一种方式实现
ExpandableListView额外支持的xml属性
编写布局文件
建立数组,用于列表展示
创建私有方法,用于各级列表项的显示
扩展BaseExpandableListAdapter来实现ExpandableListAdapter
关键是实现getGroupView(),getChildView()两方法
完整代码及部分说明
效果图
标签:Android,ExpandableListView,组件