Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/codeigniter/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用expandablelistview在android中的其他组中动态创建组。_Android_Expandablelistview - Fatal编程技术网

使用expandablelistview在android中的其他组中动态创建组。

使用expandablelistview在android中的其他组中动态创建组。,android,expandablelistview,Android,Expandablelistview,我已经成功地开发了一个可扩展的ListView。现在我需要在另一个expandablelistview中使用expandablelistview。如何在android expandablelistview中的其他组中创建组。请帮帮我。如何实现它 这是我创建两个组(orderinfo、customerinfo)的代码 final LayoutInflater LayoutInflater=(LayoutInflater)this.getSystemService(Context.LAYOUT\u

我已经成功地开发了一个可扩展的ListView。现在我需要在另一个expandablelistview中使用expandablelistview。如何在android expandablelistview中的其他组中创建组。请帮帮我。如何实现它

这是我创建两个组(orderinfo、customerinfo)的代码

final LayoutInflater LayoutInflater=(LayoutInflater)this.getSystemService(Context.LAYOUT\u INFLATER\u SERVICE);
最终ArrayList headerData=新ArrayList();
final HashMap group1=新HashMap();
组1.put(名称,“订单信息”);
headerData.add(第1组);
final HashMap group2=新HashMap();
组2.put(名称“CustomerInfo”);
headerData.add(第2组);

现在我需要在创建的另外3个组中实现customerinfo。如何做到这一点。请给我示例代码。

如果您只想要一个标准的可扩展列表视图,我建议查看示例:

路径:android sdk\samples\android-8\ApiDemos\src\com\example\android\api\view

  • ExpandableList1.java
  • ExpandableList2.java
  • ExpandableList3.java
如果您希望超过2层请从这里继续阅读:

我以前没有这样做过,但我相信您试图实现的是一个n阶exanpdablelistview。这里还有一个帖子可能会让你感兴趣:

从这里的另一篇文章:看来你无法用常规的expandablelistview实现这一点,因此你必须:

  • 从scatch创建您自己的expandablelistview
  • 对于前2个LVL使用可扩展列表视图,并使用linearlayout等创建最后一个标高
  • 使用滚动视图中分层的视图制作所有内容
  • 试试看

    final LayoutInflater layoutInflater = (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        final ArrayList<HashMap<String, String>> headerData = new ArrayList<HashMap<String, String>>();
    
        final HashMap<String, String> group1 = new HashMap<String, String>();
        group1.put(NAME, "OrderInfo");
        headerData.add( group1 );
    
        final HashMap<String, String> group2 = new HashMap<String, String>();
        group2.put(NAME, "CustomerInfo");
        headerData.add( group2);