zoukankan      html  css  js  c++  java
  • ExpandableList列表的简单应用

    package src.com;

    import java.util.ArrayList;
    import java.util.HashMap;
    import java.util.List;
    import java.util.Map;

    import android.app.Activity;
    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;

    /** Called when the activity is first created. */
    @Override
    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 < 4; i++ ){
    Map<String,String> curGroupMap = new HashMap<String,String>();
    groupData.add(curGroupMap);
    curGroupMap.put(SHELF, "BookShelf-"+i);

    List<Map<String,String>> children = new ArrayList<Map<String,String>>();

    for( int j = 1; j < 3; 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);
    }
    }

  • 相关阅读:
    js window对象
    js 静态私有变量
    [WPF][ListBox]鼠标拖拽多选,(Shift Key、Ctrl Key多选有效)(转)
    GitLab关于SSH的使用
    Git命令--保存用户名和密码
    正则表达式
    WPF创建SignalR服务端(转)
    wpf学习之(IValueConverter)
    silverlight数据绑定模式TwoWay,OneWay,OneTime的研究
    WPF样式学习三
  • 原文地址:https://www.cnblogs.com/xingmeng/p/2419833.html
Copyright © 2011-2022 走看看