ExpandableListView的使用

借用****来保存我的代码~方便查看~

ExpandableListView与Listview差不多~

先上效果图:

ExpandableListView的使用

点击问题1的答案1出现的效果图:

ExpandableListView的使用

1.首先在项目的activtiy_main.xml中添加:

ExpandableListView的使用

2.既然是二级列表,所以新建两个ExpandableListView的内容布局:

(1)expand_group_item.xml

ExpandableListView的使用

(2)expand_child_item.xml

ExpandableListView的使用

3.Adapter

首先adapter继承了BaseExpandableListAdapter

用数组写了需要用的数据,没有单独起类

ExpandableListView的使用

ExpandableListView的使用

继承BaseExpandableListAdapter会生成很多方法

ExpandableListView的使用

添加方法后修改一下~

ExpandableListView的使用

ExpandableListView的使用

对于hasStableIds()方法作用是网上看来的~ExpandableListView的使用

ExpandableListView的使用

至此adapter里写完了 ~

4.MainActivity.java

ExpandableListView的使用

完成!