ExpandableListActivity 的使用
来源:互联网 发布:淘宝土家酱香饼纸袋 编辑:程序博客网 时间:2024/06/05 02:35
ExpandableListActivity是一个可膨胀的ListActivity,看一下实现的效果:
import android.app.ExpandableListActivity;
import android.os.Bundle;
import android.widget.ExpandableListAdapter;
import android.widget.SimpleExpandableListAdapter;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* Demonstrates expandable lists backed by a Simple Map-based adapter
*/
public class ExpandableList3 extends ExpandableListActivity {
private static final String NAME = "NAME";
private static final String IS_EVEN = "IS_EVEN";
private ExpandableListAdapter mAdapter;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//填充groupdata和childdata
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 = 0; i < 20; i++) {
Map<String, String> curGroupMap = new HashMap<String, String>();
groupData.add(curGroupMap);
curGroupMap.put(NAME, "Group " + i);
curGroupMap.put(IS_EVEN, (i % 2 == 0) ? "This group is even" : "This group is odd");
List<Map<String, String>> children = new ArrayList<Map<String, String>>();
for (int j = 0; j < 15; j++) {
Map<String, String> curChildMap = new HashMap<String, String>();
children.add(curChildMap);
curChildMap.put(NAME, "Child " + j);
curChildMap.put(IS_EVEN, (j % 2 == 0) ? "This child is even" : "This child is odd");
}
childData.add(children);
}
// 使用SimpleExpandableListAdapter
// Set up our adapter
mAdapter = new SimpleExpandableListAdapter(
this,//上下文
groupData,//父目录数据
android.R.layout.simple_expandable_list_item_1,//父目录布局
new String[] { NAME, IS_EVEN },//从groupDatg获取相应数据
new int[] { android.R.id.text1, android.R.id.text2 },//填充到相应布局中
childData,//子。。。。一样的不重复
android.R.layout.simple_expandable_list_item_2,
new String[] { NAME, IS_EVEN },
new int[] { android.R.id.text1, android.R.id.text2 }
);
setListAdapter(mAdapter);
}
}
- [Android] ExpandableListActivity的使用
- ExpandableListActivity的使用
- ExpandableListActivity 的使用
- ExpandableListActivity的学习和使用
- ExpandableListActivity的使用和SimpleExpandableListAdapter的使用
- 可展开的Activity ExpandableListActivity的使用
- android学习--ExpandableListActivity和SimpleExpandableListAdapter的使用
- android startActivtyForResult以及ExpandableListActivity的使用
- 使用ExpandableListActivity实现可展开的Activity
- ExpandableListActivity使用findViewById查找child中view的时序问题
- Android上 ExpandableListActivity及CursorTreeAdapter的使用简介
- ExpandableListView 和 ExpandableListActivity的使用及数据更新
- Android上 ExpandableListActivity及CursorTreeAdapter的使用简介
- android打下扎实基础-----ExpandableListActivity类的使用
- 第八课:Activity 及其子类的使用二:ExpandableListActivity
- ExpandableListActivity的基本实现
- ExpandableListActivity
- ExpandableListActivity
- java垃圾回收机制
- 大话设计模式C++实现-第25章-中介者模式
- WordPress程序打开速度慢的三种解决方法
- Spring MVC 学习笔记8 —— 实现简单的用户管理(4)
- Android 基于google Zxing实现二维码、条形码扫描,仿微信二维码扫描效果
- ExpandableListActivity 的使用
- 小白学c++之多线程互斥锁
- maven assembly打出的独立可执行jar包找不到xml schema解决,使用shade插件
- adobe flash player升级coredump分析
- 判斷選擇的日期區間必須在某個範圍內,比如選擇的日期區間在必須三個月內
- Android 开源框架ActionBarSherlock 和 ViewPager 仿网易新闻客户端
- 正则表达式初步
- js 动态合并表格单元格
- 产品经理们都是怎样养成的?