android------列中列的列表ExpandableListActivity对象
来源:互联网 发布:淘宝4.0旧版 编辑:程序博客网 时间:2024/06/05 00:31
1、main.xml代码:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingBottom="@dimen/activity_vertical_margin" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin" android:paddingTop="@dimen/activity_vertical_margin" tools:context=".Activity01" ><ExpandableListView android:id="@id/android:list" android:layout_width="fill_parent" android:layout_height="wrap_content" android:drawSelectorOnTop="false"/> <TextView android:id="@id/android:empty" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="NO data!"/> <!-- android:drawSelectorOnTop="false" 是选项高亮部分不覆盖文字 --></RelativeLayout>
2、group.xml代码:
<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" > <TextView android:id="@+id/groupto"android:layout_width="fill_parent" android:layout_height="fill_parent" android:paddingLeft="60px" android:textSize="26sp" android:text="NO DATA!"/></LinearLayout>
3、child.xml代码:
<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" > <TextView android:id="@+id/childto"android:layout_width="fill_parent" android:layout_height="fill_parent" android:paddingLeft="60px" android:textSize="20sp" android:text="NO DATA!"/></LinearLayout>4、Activity01.java代码:
package mars.expandablelistactivity;import java.util.ArrayList;import java.util.HashMap;import java.util.List;import java.util.Map;import android.os.Bundle;import android.widget.SimpleExpandableListAdapter;import android.app.ExpandableListActivity;public class Activity01 extends ExpandableListActivity {protected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.main);//定义一个List,为一级条目提供数据List<Map<String,String>> groups=new ArrayList<Map<String,String>>();Map<String,String> group1=new HashMap<String,String>();group1.put("group", "group1");Map<String,String> group2=new HashMap<String,String>();group2.put("group", "group2");groups.add(group1);groups.add(group2);//定义一个List,为第一个条目增加二级条目的数据List<Map<String,String>> child1=new ArrayList<Map<String,String>>();Map<String,String> childDate1=new HashMap<String,String>();childDate1.put("child", "childDate1");Map<String,String> childDate2=new HashMap<String,String>();childDate2.put("child", "childDate2");child1.add(childDate1);child1.add(childDate2);//定义一个List,为第二个条目增加二级条目的数据List<Map<String,String>> child2=new ArrayList<Map<String,String>>();Map<String,String> childDate3=new HashMap<String,String>();childDate3.put("child", "childDate1");child2.add(childDate3);//定义一个List,存储所有二级条目的数据List<List<Map<String,String>>> childs=new ArrayList<List<Map<String,String>>>();childs.add(child1);childs.add(child2);SimpleExpandableListAdapter sela=new SimpleExpandableListAdapter(this,groups,R.layout.group,new String[]{"group"},new int[]{R.id.groupto},childs,R.layout.child,new String[]{"child"},new int[]{R.id.childto});setListAdapter(sela);}}5、运行效果:
0 0
- android------列中列的列表ExpandableListActivity对象
- [Android] ExpandableListActivity的使用
- Android-ExpandableListActivity
- android ExpandableListActivity
- Android UI ExpandableListActivity与ExpandableListActivity
- Android ExpandableListActivity实现可展开的activity
- android学习--ExpandableListActivity和SimpleExpandableListAdapter的使用
- android startActivtyForResult以及ExpandableListActivity的使用
- 使用ExpandableListActivity显示扩展列表
- Android ExpandableListActivity 学习笔记
- Android ExpandableListActivity 学习笔记
- Android基础之ExpandableListActivity
- Android开发--浅谈ExpandableListActivity
- (android 基础知识) ExpandableListActivity
- android ExpandableListActivity简介
- Android基础之ExpandableListActivity
- android ExpandableListActivity 练习
- android之ExpandableListActivity
- linux总线、设备和驱动程序
- Linux内核抢占机制(preempt)
- 2013年6月 第三套 two long conversations
- STL&容器
- Oracle常用监控SQL
- android------列中列的列表ExpandableListActivity对象
- IOS沙盒机制和文件操作(3)
- SUID/SGID/SBIT 權限設定
- QuickFAST:Why can't I run the performance test? Why can't I run the example programs?
- wireshark字符串匹配string.find的问题
- 算法竞赛入门经典-前四章-UVa10300 - Ecological Premium-生态奖金-难度0
- Linux下安装OpenCV
- tomcat学习笔记(三) Connector
- C++编程技巧攻略