ExpandableList列表的简单应用
来源:互联网 发布:莱昂纳德 知乎 编辑:程序博客网 时间:2024/05/07 03:23
package com.test;
//Download by http://ww.codefans.net
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.test.R.string;
import android.R.bool;
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 < 5; i++) {
Map<String, String> curGroupMap = new HashMap<String, String>();
//将curGroupMap赋值给groupData
groupData.add(curGroupMap);
curGroupMap.put(SHELF, "Bookshelfs-" + i);
List<Map<String, String>> children = new ArrayList<Map<String, String>>();
for (int j = 1; j < 4; 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);
}
}
//Download by http://ww.codefans.net
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.test.R.string;
import android.R.bool;
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 < 5; i++) {
Map<String, String> curGroupMap = new HashMap<String, String>();
//将curGroupMap赋值给groupData
groupData.add(curGroupMap);
curGroupMap.put(SHELF, "Bookshelfs-" + i);
List<Map<String, String>> children = new ArrayList<Map<String, String>>();
for (int j = 1; j < 4; 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);
}
}
0 0
- ExpandableList列表的简单应用
- 简单的ExpandableList控件例子
- ExpandableList的用法
- ExpandableList
- expandablelist
- Adapter类控件使用之ExpandableList(可折叠式列表)的基本使用
- Android之可收缩展开列表ExpandableList
- android ExpandableList的自动收起
- ExpandableList------可扩展的list
- 一个简单的Ajax下拉列表应用
- 一个简单的todo列表应用
- 关于使用扩展列表ExpandableList数据接口问题(一)
- 定制自己的ExpandableList(实现checkable)
- android-ExpandableList可展开的list
- Android常用控件之ExpandableList的使用
- [C++]数据结构:散列表HashTable的实现与简单应用
- Java下拉列表的简单应用(JComboBox)
- 作用域插槽列表的简单应用实例
- PropertiesTest
- swt体系结构
- Android 圆形按钮实现
- TelephonyManager获取SIM卡信息
- 位域
- ExpandableList列表的简单应用
- Linux 分区及磁盘挂载
- 常用的tcp/ip协议及端口
- 使用 Spring Data JPA 简化 JPA 开发
- Oracle表空间删除报错问题的解决
- 【Kernel Method系列】Kernel Method入门
- 测试用例的生命周期回调
- 一些资料
- oracle中exp,imp的使用详解