package com.test;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import android.app.ExpandableListActivity;
import android.os.Bundle;
import android.widget.ExpandableListAdapter;
import android.widget.SimpleExpandableListAdapter;
public class expandableList extends ExpandableListActivity {
private static final String SHELF = "SHELF";
private static final String BOOK = "BOOK";
private ExpandableListAdapter mAdapter;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
List<Map<String, String>> groupData = new ArrayList<Map<String, String>>();
List<List<Map<String, String>>> childData = new ArrayList<List<Map<String, String>>>();
for (int i = 1; i < 4; i++) {
Map<String, String> curGroupMap = new HashMap<String, String>();
groupData.add(curGroupMap);
curGroupMap.put(SHELF, "Bookshelf-" + i);
List<Map<String, String>> children = new ArrayList<Map<String, String>>();
for (int j = 1; j < 3; j++) {
Map<String, String> curChildMap = new HashMap<String, String>();
children.add(curChildMap);
curChildMap.put(SHELF, "Book- " + j);
}
childData.add(children);
}
// Set up our adapter
mAdapter = new SimpleExpandableListAdapter(
this,
groupData,
android.R.layout.simple_expandable_list_item_1,
new String[] { SHELF, BOOK},
new int[] { android.R.id.text1, android.R.id.text2 },
childData,
android.R.layout.simple_expandable_list_item_2,
new String[] { SHELF, BOOK},
new int[] { android.R.id.text1, android.R.id.text2 }
);
setListAdapter(mAdapter);
}
}
Android应用源码之ExpandableList(二级树的构造)-IT计算机-毕业设计.zip
版权申诉
177 浏览量
2022-04-06
20:46:22
上传
评论
收藏 61KB ZIP 举报
芝麻粒儿
- 粉丝: 6w+
- 资源: 2万+
最新资源
- java毕业设计+扫雷(程序)
- strawberry-perl-5.38.2.2-64bit.msi
- MeyboMail Web(Java)简化版
- java(结合lucene)版的公交搜索系统
- 【OpenHarmony】ArkTS 语法基础 ④ ( ArkTS UI 渲染控制 - 条件渲染 - 循环渲染 )
- 稽查监控平台标准化设计数据模型设计
- 一款极好用的 Office/WPS/Word/Excel/PPT/PDF工具箱软件 OfficeUtils 2.7
- 基于STM32的家庭环境参数检测系统设计
- 夺宝答题王答题小程序源码 开源可二开 Thinkphp内核
- Linux 系统下 Hadoop 安装配置教程.md
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈