main-activity
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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:orientation="vertical"
    tools:context="com.zpj.aaa.expandablelistview.MainActivity"><ExpandableListView
        android:id="@android:id/list"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:drawSelectorOnTop="false"></ExpandableListView>
</LinearLayout>

father-activity
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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:orientation="vertical"
    tools:context="com.zpj.aaa.expandablelistview.MainActivity"><TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/tv_father"
son的格式和father的布局格式差不多。 id 为tv_son
        android:text="none"
        android:textSize="50dp" /></LinearLayout>
实现方法  Java
  //为一级条目提供数据
  List<Map<String,String>> groups = new ArrayList<>();Map<String,String> group1 = new HashMap<>();group1.put("group","group1");Map<String,String> group2 = new HashMap<>();group2.put("group","group2");groups.add(group1);groups.add(group2);//为二级条目提供数据
  List<Map<String,String>> child1 = new ArrayList<>();Map<String,String> child1Date1 = new HashMap<>();child1Date1.put("child","child1Date1");Map<String,String> child1Date2 = new HashMap<>();child1Date2.put("child","child1Date2");child1.add(child1Date1);child1.add(child1Date2);List<Map<String,String>> child2 = new ArrayList<>();Map<String,String> child2Date1 = new HashMap<>();child2Date1.put("child","child2Date1");child2.add(child2Date1);List<List<Map<String,String>>> childs = new ArrayList<List<Map<String,String>>>();childs.add(child1);childs.add(child2);/*
   * 第一个参数  应用程序接口 this
   * 第二个父列List<?extends Map<String,Object>>集合 为父列提供数据
   * 第三个参数  父列显示的组件资源文件
   * 第四个参数  键值列表 父列Map字典的key
   * 第五个要显示的父列组件id
   * 第六个 子列的显示资源文件
   * 第七个参数 键值列表的子列Map字典的key
   * 第八个要显示子列的组件id*/
  // adapter
  SimpleExpandableListAdapter sela = new SimpleExpandableListAdapter(MainActivity.this,groups,R.layout.activity_father,new String[]{"group"},new int[]{R.id.tv_father},childs,// (List<? extends List<? extends Map<String, ?>>>) childs,
          R.layout.activity_son,new String[]{"child"},new int[]{R.id.tv_son});setListAdapter(sela);

												

expandablelist相关推荐

  1. 控件(View)之TextSwitcher, Gallery, ImageSwitcher, GridView, ListView, ExpandableList【转】

    在 Android 中使用各种控件(View) TextSwitcher - 文字转换器控件(改变文字时增加一些动画效果) Gallery - 缩略图浏览器控件 ImageSwitcher - 图片转 ...

  2. Android中 ExpandableList的使用2

    Android中ExpandableList的使用2 本文介绍Android中ExpandableList的使用,在前文的基础上作了很多改进,增加了增加.删除.回调等功能. 图中的 "第一行 ...

  3. 可折叠列表ExpandableList

    ExpandableList就是可展开的ListView 首先我们来看一下页面的布局 expandlist_layout.xml文件 <RelativeLayout xmlns:android= ...

  4. Android常用控件之ExpandableList的使用

    先来看下什么是ExpandableListView 跟列表有点像,这种是可以折叠的列表,下面来看下是如何在代码中实现 一.在布局文件中声明一个ExpandableListView <Linear ...

  5. android 二级折叠列表,Android折叠列表 ExpandableList

    ExpandableList 是折叠列表,通过继承ExpandableListActivity 类就可以非常简单的实现折叠列表. 效果图: 代码实现 package com.zhou.activity ...

  6. android 展开菜单,Android之可收缩展开列表ExpandableList

    在Android的app包中,有这么一个类,这个类继承自Activity,它叫ExpandableListActivity.顾名思义,从它的名字可以看出该类是一种可扩展性的列表List,我们这里理解成 ...

  7. Android ExpandableList扩展用法

    1.简介 基于基于BaseExpandableListAdapter扩展的ExpandableList用法,现在网上流行的主要有两种:第一种是向BaseExpandableListAdapter传入两 ...

  8. ExpandableList扩展用法

    1.简介 基于BaseExpandableListAdapter扩展的ExpandableList用法,现在网上流行的主要有两种:第一种是向BaseExpandableListAdapter传入两个数 ...

  9. ExpandableList自定义动画效果

    项目中使用ExpandableList,要求分组展开时显示一个动画, 问题: 动画效果位于GroupView上,适配器中getGroupView方法通过判断当前项是点击的分组, 然后进行展开和收起的动 ...

  10. RN如何实现一个ExpandableList(可展开列表)组件

    前言 今天想跟大家分享一个用RN实现的组件 - ExpandableList.恩,没什么特殊的原因,只是因为最近有一个需求要用到这东西,而且RN没有提供现成的组件,所以很(不)开(得)心(已)地做了一 ...

最新文章

  1. 附录:PyTorch记事本
  2. Vue.js 过滤器
  3. js设计模式每次10分钟:字面量和构造函数模式对比
  4. Learning Less is More – 6D Camera Localization via 3D Surface Regression
  5. 使用.Net Core实现的一个图形验证码
  6. inputstream重新赋值之前需要close吗_变量提升真的搞懂了吗?打脸的一道题
  7. IIS7报“假”正式版随Server 2008发布
  8. Spring for Apache Hadoop 1.0 GA
  9. IME输入法编程心得
  10. 自己写代码解析工具的注意事项
  11. python汉字转gb2312_PYTHON中UTF-8向GB2312编码转换的问题一解
  12. shell中变量截取
  13. 【转载】批量维护(创建/修改)客户主数据函数 SD_CUSTOMER_MAINTAIN_ALL BP自定义屏幕 数据维护
  14. 渲染到纹理(Render To Texture, RTT)
  15. 搭建hexo博客与yilia主题优化
  16. 虚拟机 报错:Unmount and run xfs_repair
  17. hihoCoder #1135 : Magic Box
  18. 回顾南仁东先生-时代楷模(FAST之父)//2021-2-6
  19. JWB1: webapp相关简介
  20. 千变万化的ViewPager指示器-MagicIndicator

热门文章

  1. 容器单机编排工具 Docker Compose,swap 限制,配置默认的CFS调度程序,Stress-ng 压力测试工具,docker官网镜像上传,及阿里云镜像上传,Docker 的资源限制
  2. java Map集合深入解析
  3. matlab计算层次法的权重,层次分析法计算权重在matlab中的实现
  4. IT公司的妇女节都怎么过的
  5. 狂奔的蔚来:上市背后的必然与隐忧
  6. 读其他俱乐部WeeklyReport
  7. Android 需要学习的UI框架
  8. 【转】共享经济是临时工的增量市场?
  9. 微信小程序下载视频文件wx.downloadFile下载资源失败
  10. Elasticsearch从入门到放弃:索引基本使用方法