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);
}
}
荣华富贵8
- 粉丝: 215
- 资源: 7653
最新资源
- 11月美宝莲专卖店背柜完稿740mmX400mm
- 通过 stdio 进行简单(但高效)的进程间通信,从 Node.js 运行 Python 脚本.zip
- STM32F030F4P6-LOCK+OLED
- 11月美宝莲专卖店grab&go完稿 grab&go-o.ai
- 2023-04-06-项目笔记 - 第三百二十七阶段 - 4.4.2.325全局变量的作用域-325 -2025.11.24
- 章节2:编程基本概念之python对象的基本组成和内存示意图
- 适用于 Raspberry Pi 的 Adafruit 库代码.zip
- 章节2:编程基本概念之python程序的构成
- 适用于 Python 的 LINE 消息 API SDK.zip
- 宝塔面板安装及关键网络安全设置指南
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈