groupListview.jave中: package com.example.groupListView; 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.SimpleExpandableListAdapter; public class groupListView extends ExpandableListActivity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); 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<Map<String,String>> child1 = new ArrayList<Map<String,String>>(); Map<String,String> child1data1 = new HashMap<String,String>(); child1data1.put("child", "child1data1"); child1.add(child1data1); Map<String,String> child1data2 = new HashMap<String,String>(); child1data2.put("child", "child1data2"); child1.add(child1data2); List<Map<String,String>> child2 = new ArrayList<Map<String,String>>(); Map<String,String> child2data1 = new HashMap<String,String>(); child2data1.put("child", "child2data1"); child2.add(child2data1); List<List<Map<String,String>>> childs = new ArrayList<List<Map<String,String>>>(); childs.add(child1); childs.add(child2); SimpleExpandableListAdapter adapter = 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(adapter); } } child.xml <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" > <TextView android:id="@+id/childTo" android:layout_width="fill_parent" android:layout_height="wrap_content" android:paddingLeft="50px" android:paddingTop="5px" android:paddingBottom="5px" android:textSize="20sp" android:text="no data" /> </LinearLayout> group.xml <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" > <TextView android:id="@+id/groupTo" android:layout_width="fill_parent" android:layout_height="wrap_content" android:paddingLeft="60px" android:paddingTop="10px" android:paddingBottom="10px" android:textSize="26sp" android:text="no data" /> </LinearLayout> main.xml <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" > <ExpandableListView android:id="@id/android:list" android:layout_width="fill_parent" android:layout_height="fill_parent" android:drawSelectorOnTop="false" /> <TextView android:id="@id/android:empty" android:layout_width="fill_parent" android:layout_height="fill_parent" android:text="no data" /> </LinearLayout>