package com.Ina.Expand;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import android.app.ExpandableListActivity;
import android.app.IntentService;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ExpandableListView;
import android.widget.SimpleExpandableListAdapter;
public class ExpandActivity extends ExpandableListActivity
{
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
//创建二个一级条目标题
Map<String, String> title_1 = new HashMap<String, String>();
Map<String, String> title_2 = new HashMap<String, String>();
title_1.put("group", "开发");
title_2.put("group", "管理");
//创建一级条目容器
List<Map<String, String>> gruops = new ArrayList<Map<String,String>>();
gruops.add(title_1);
gruops.add(title_2);
//创建二级条目内容
//内容一
Map<String, String> content_1 = new HashMap<String, String>();
Map<String, String> content_2 = new HashMap<String, String>();
content_1.put("child", "VC++");
content_2.put("child", "Java");
List<Map<String, String>> childs_1 = new ArrayList<Map<String,String>>();
childs_1.add(content_1);
childs_1.add(content_2);
//内容二
Map<String, String> content_3 = new HashMap<String, String>();
Map<String, String> content_4 = new HashMap<String, String>();
content_3.put("child", "敏捷开发");
content_4.put("child", "迭代开发");
List<Map<String, String>> childs_2 = new ArrayList<Map<String,String>>();
childs_2.add(content_3);
childs_2.add(content_4);
//存放两个内容, 以便显示在列表中
List<List<Map<String, String>>> childs = new ArrayList<List<Map<String,String>>>();
childs.add(childs_1);
childs.add(childs_2);
//创建ExpandableList的Adapter容器
//参数: 1.上下文 2.一级集合 3.一级样式文件 4. 一级条目键值 5.一级显示控件名
// 6. 二级集合 7. 二级样式 8.二级条目键值 9.二级显示控件名
SimpleExpandableListAdapter sela = new SimpleExpandableListAdapter(
this, gruops, R.drawable.groups, new String[]{"group"}, new int[]{R.id.textGroup},
childs, R.drawable.childs, new String[]{"child"}, new int[]{R.id.textChild}
);
//加入列表
setListAdapter(sela);
Intent intent = new Intent();
intent.setClass(this, ExpandControlActivity.class);
startActivity(intent);
}
//列表内容按下
@Override
public boolean onChildClick(ExpandableListView parent, View v,
int groupPosition, int childPosition, long id)
{
// TODO Auto-generated method stub
return super.onChildClick(parent, v, groupPosition, childPosition, id);
}
//二级标题按下
@Override
public boolean setSelectedChild(int groupPosition, int childPosition,
boolean shouldExpandGroup)
{
// TODO Auto-generated method stub
return super.setSelectedChild(groupPosition, childPosition, shouldExpandGroup);
}
//一级标题按下
@Override
public void setSelectedGroup(int groupPosition)
{
// TODO Auto-generated method stub
super.setSelectedGroup(groupPosition);
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
ExpandableListView 展开列表控件
共30个文件
class:8个
png:6个
xml:6个
5星 · 超过95%的资源 需积分: 11 484 下载量 169 浏览量
2012-03-09
16:06:19
上传
评论 2
收藏 56KB RAR 举报
温馨提示
ExpandableListView 展开列表控件 教程请看 http://blog.csdn.net/knowheart/article/details/7002079
资源推荐
资源详情
资源评论
收起资源包目录
Expand.rar (30个子文件)
Expand
bin
classes.dex 5KB
res
drawable-ldpi
ic_launcher.png 2KB
drawable-hdpi
ic_launcher.png 4KB
drawable-mdpi
ic_launcher.png 2KB
Expand.apk 17KB
classes
com
Ina
Expand
ExpandControlActivity.class 2KB
R$layout.class 412B
R$id.class 442B
R$drawable.class 455B
R$attr.class 328B
ExpandActivity.class 3KB
R.class 503B
R$string.class 415B
resources.ap_ 12KB
res
drawable-ldpi
ic_launcher.png 2KB
drawable-hdpi
ic_launcher.png 4KB
groups.xml 515B
childs.xml 526B
values
strings.xml 178B
drawable-mdpi
ic_launcher.png 3KB
layout
expand.xml 415B
main.xml 416B
assets
gen
com
Ina
Expand
R.java 1008B
proguard.cfg 1KB
src
com
Ina
Expand
ExpandControlActivity.java 2KB
ExpandActivity.java 3KB
.project 842B
.classpath 364B
project.properties 360B
AndroidManifest.xml 801B
共 30 条
- 1
克雷斯
- 粉丝: 36
- 资源: 12
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
- 1
- 2
- 3
- 4
- 5
- 6
前往页