public class ExpandLV extends ExpandableListActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
List<HashMap<String,String>> group=new ArrayList<HashMap<String,String>>();
HashMap<String,String> groupitem1=new HashMap<String, String>();
groupitem1.put("name", "lin");
group.add(groupitem1);
HashMap<String,String> groupitem2=new HashMap<String, String>();
groupitem2.put("name", "hzc");
group.add(groupitem2);
HashMap<String,String> groupitem3=new HashMap<String, String>();
groupitem3.put("name", "gege");
group.add(groupitem3);
List<List<HashMap<String,String>>> child=new ArrayList<List<HashMap<String,String>>>();
List<HashMap<String,String>> child1=new ArrayList<HashMap<String,String>>();
HashMap<String,String> child1item1=new HashMap<String, String>();
groupitem1.put("name", "lin");
child1.add(groupitem1);
HashMap<String,String> child2item2=new HashMap<String, String>();
groupitem2.put("name", "hzc");
child1.add(groupitem2);
HashMap<String,String> child3item3=new HashMap<String, String>();
groupitem3.put("name", "gege");
child1.add(groupitem3);
child.add(child1);
SimpleExpandableListAdapter sea=new SimpleExpandableListAdapter(this, group,android.R.layout.simple_expandable_list_item_1
, android.R.layout.simple_expandable_list_item_1, new String[]{"name"}, new int[]{R.id.text1},
child, android.R.layout.simple_expandable_list_item_1, new String[]{"name"}, new int[]{R.id.text1});
setListAdapter(sea);
}
}
ExpandableListActivity
最新推荐文章于 2019-04-03 18:37:34 发布