ExpandableListView的使用
借用****来保存我的代码~方便查看~
ExpandableListView与Listview差不多~
先上效果图:
点击问题1的答案1出现的效果图:
1.首先在项目的activtiy_main.xml中添加:
2.既然是二级列表,所以新建两个ExpandableListView的内容布局:
(1)expand_group_item.xml
(2)expand_child_item.xml
3.Adapter
首先adapter继承了BaseExpandableListAdapter
用数组写了需要用的数据,没有单独起类
继承BaseExpandableListAdapter会生成很多方法
添加方法后修改一下~
对于hasStableIds()方法作用是网上看来的~
至此adapter里写完了 ~
4.MainActivity.java
完成!