一、知识点
1、ExpandableListView是LIstView的子类,它在普通ListView的基础上进行了 扩展,它把应用的列表项分成了几组,每组又可包含多个列表项。
2、ExpandablelistView 的用法与普通的ListView的 用法相似,只是ExpandableListView所显示的列表项应该由ExpandableListAdapter提供,实现ExpandablelistAdaptery有如下三种常用方式:
- 扩展BaseExpandableListAdapter实现ExpandableListAdapter
- 使用SimpleExpandableListAdapter将两个List集合包装成ExpandableListAdapter
- 使用SimpleExpandableListAdapter将Cursor中的数据包装成SimpleCursorTreeAdapter
3、调用BaseExpandableListAdapter需要重写的10个方法
- public Object getChild(int groupPosition, int childPosition)
- 获取指定组中的指定子元素数据。返回值,返回指定子元素数据。
- public long getChildId(int groupPosition, int childPosition)
- 获取指定组中的指定子元素ID,这个ID在组里一定是唯一的。
- public View getChildView(int groupPosition, int childPosition, boolean isLastChild, View convertView,ViewGroup parent)
- 获取一个视图对象,显示指定组中的指定子元素数据。