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

    package com.test;
    //Download by http://ww.codefans.net
    import java.util.ArrayList;
    import java.util.HashMap;
    import java.util.List;
    import java.util.Map;

    import com.test.R.string;

    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;

        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 < 5; 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 < 4; 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);
            
        }
    }

  • 相关阅读:
    对soc-audio体系snd_soc_machine和snd_soc_dai_link简单理解
    I2S
    alsa和oss声音系统比较
    break 和 continue
    phalcon查询:单条查询,多条查询,多表查询
    phalcon: 独立的映射,字段名名别名
    phpexcel: 数据导出
    php:Mcrypt响应慢的原因解决备注
    js:s上次预览,上传图片预览,图片上传预览
    yii2: 点击编辑后,左侧的连接(a.navtab)失效,变成在新窗口打开
  • 原文地址:https://www.cnblogs.com/ahao214/p/3818532.html
Copyright © 2011-2022 走看看