ExpandableListAdapter
来源:互联网 发布:360软件应用中心 编辑:程序博客网 时间:2024/06/06 14:00
1在布局文件中声明expandablelistActivity
<ExpandableListView android:id="@id/android:list"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:drawSelectorOnTop="false"
/>
<TextView
android:id="@id/android:empty"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="No data" />
2在布局文件中声明group式样
group.xml
<TextView android:id="@+id/groupTo"
android:layout_width="fill_parent"
android:lyaout_height="fill_parent"
android:paddingLeft="60px"
android:paddingTop="10px"
android:paddingBottom="10px"
android:textSize="26sp"
android:text="Nodata"/>
3 布局文件中声明child式样
<TextView android:id="@+id/childTo"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:paddingLeft="50px"
android:paddingTop="5px"
android:paddingBottom="5px"
android:textSize="20sp"
android:text="Nodata"/>
4定义list 为一级条目提供数据
List<Map<String,String>> groups = new ArrayList<Map<String,String>>();
Map<String,String> group1 = new HashMap<String,String>();
group1.put("group", "group1");
Map<String,String> group2 = new HashMap<String,String>();
group2.put("group", "group2");
groups.add(group1);
groups.add(group2);
5 定义list为一级条目提供二条二级条目数据
//定义一个list,该list为第一个一级条目提供二级条目的数据
List<Map<String,String>> child1 = new ArrayList<Map<String,String>>();
Map<String,String> child1data1 = new HashMap<String,String>();
child1data1.put("child", "child1data1");
child1.add(child1data1);
Map<String,String> child1data2 = new HashMap<String,String>();
child1data2.put("child", "child1data2");
child1.add(child1data2);
// 定义一个List,该List对象为第二个一级条目提供二级条目的数据
List<Map<String,String>> child2 = new ArrayList<Map<String,String>>();
Map<String,String> child2data = new HashMap<String,String>();
child2data.put("child", "child2data");
child2.add(child2data);
//定义一个List,该List对象用来存储所有的二级条目的数据
List<List<Map<String,String>>> childs = new ArrayList<List<Map<String,String>>>();
childs.add(child1);
childs.add(child2);
6 定义simpleExpandableListAdapter对象为ExpandableListAdapter提供数据
SimpleExpandableListAdapter sela = new SimpleExpandableListAdapter(
this,groups,R.layout.group,new String[]{"group"},new int[]{R.id.groupTo},childs,
R.layout.child,new String[]{"child"},new int[]{R.id.childTo});
setListAdapter(sela);
- ExpandableListAdapter
- ExpandableListAdapter
- ExpandableListAdapter
- ExpandableListAdapter
- 关于ExpandableListAdapter
- ExpandableListAdapter适配器
- 数据适配器简介(ExpandableListAdapter)
- 万能ExpandableListAdapter适配器
- ExpandableListAdapter详细介绍
- ExpandableListAdapter二级菜单适配器
- 二级列表SimpleExpandableListAdapter ,ExpandableListAdapter
- 使用ExpandableListView和ExpandableListAdapter实现分组列表
- 入门篇ExpandableListAdapter(简易树形组件)
- 第24章:ExpandableListAdapter的用法
- Android7.0中文文档(API)-- ExpandableListAdapter
- 用ExpandableListAdapter在每个child列表前添加图片
- (自定义ListView控件)在ExpandableListAdapter中嵌套ListView
- ~~~关于ExpandableListAdapter的一个比较二的问题,求解啊~~~
- iOS开发如何实现消息推送机制
- Linux下查看文件和文件夹大小
- zoj 2100 Seeding
- 如何获取客户端的IP地址
- UVA Live 5067/acm-icpc-Asia - Tokyo-A
- ExpandableListAdapter
- boost库的使用_tuple
- 2.一对一双向主键关联(人对身份证) 工具类
- 3.一对一双向主键关联(人对身份证) hibernate.cfg.xml
- linux sleep毫秒
- EJBCA安装教程
- 4.一对一双向主键关联(人对身份证) 测试
- PCA算法原理简介
- USTCOJ1308 全排列 JAVA读入模板