一、编写布局

二、准备数据

// 大分组List> group = new ArrayList<>();Map groupBook = new HashMap<>();groupBook.put(“group”, “西游记”);group.add(groupBook);// 组内数据List>> child = new ArrayList<>();List> childPerson = new ArrayList<>();Map childPersonData = new HashMap<>();childPersonData.put("child", "唐三藏");Map childPersonData2 = new HashMap<>();childPersonData2.put("child", "孙悟空");childPerson.add(childPersonData);childPerson.add(childPersonData2);child.add(childPerson);

三、关联数据

// 关联数据SimpleExpandableListAdapter adapter = new SimpleExpandableListAdapter(this,group,        android.R.layout.simple_expandable_list_item_1,new String[]{“group”},new int[]{android.R.id.text1},child,android.R.layout.simple_expandable_list_item_1,new String[]{“child”},new int[]{android.R.id.text1});ExpandableListView expandableListView = findViewById(R.id.expandable_listview);expandableListView.setAdapter(adapter);

四、查看效果
Android里边如何使用二级列表_第1张图片

更多相关文章

  1. Android 数据查询query函数参数解析
  2. Android向服务器提交数据(方式:get、post、AsyncHttpClient )
  3. Android 登陆、提交数据或者加载数据时提示页面
  4. Android中解析json数据的方式之一:Gson
  5. Android应用开发基础之数据存储和界面展现(一)
  6. Android Bluetooth蓝牙开发:Bluetooth蓝牙设备之间数据传输(4)
  7. 利用JDBC连接服务器数据库(Android)
  8. Android应用数据存储几种方式(3)

随机推荐

  1. Android自定义Toast弹出消息提示
  2. Android Studio Gradle 缓存文件夹设置
  3. Android(安卓)9.0模拟器root权限获取
  4. Android 用户验证(超全正则表达)
  5. Android 程序真退出与假退出后台运行详解
  6. Android(安卓)更改键盘Enter键文字
  7. android之【代码实现ImageView图片切换】
  8. Delphi XE5 Android 调用 Google ZXing
  9. android 图片叠加效果——两种方法
  10. [掌眼]iOS / Android / java / node.js