##本章目标
ExpandableListView 可展开的列表视图控件
##ExpandableListView的介绍
1、层级关系
AbsListView
ListView
ExpandableListView
GridView
2、特点
可以展示垂直滚动的二级列表,数据来自于ExpandableListAdapter
##ExpanadableListView的使用
1、找控件
findViewById
2、准备数据
String[] groups={};
String[][] names={{},{},{}};
3、设置适配器
BaseExpandableListAdapter
必须重写四个方法:
getGroupCount groups.length
getGroupView groups[]
getChildrenCount names[groupPosition].length
getChildView names[][]
4、设置监听
设置子级监听 onChildClickListener
默认不能点击,除非重写 isChildSelected方法
ExpandableListView 可展开的列表视图控件
##ExpandableListView的介绍
1、层级关系
AbsListView
ListView
ExpandableListView
GridView
2、特点
可以展示垂直滚动的二级列表,数据来自于ExpandableListAdapter
##ExpanadableListView的使用
1、找控件
findViewById
2、准备数据
String[] groups={};
String[][] names={{},{},{}};
3、设置适配器
BaseExpandableListAdapter
必须重写四个方法:
getGroupCount groups.length
getGroupView groups[]
getChildrenCount names[groupPosition].length
getChildView names[][]
4、设置监听
设置子级监听 onChildClickListener
默认不能点击,除非重写 isChildSelected方法