gpt4 book ai didi

android - 使用 expandablelistview 在 android 中的另一个组中动态创建组。

转载 作者:太空狗 更新时间:2023-10-29 15:16:48 24 4
gpt4 key购买 nike

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

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

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);

现在我需要在创建的另外 3 个组中实现 customerinfo。这该怎么做。请给我示例代码。

最佳答案

如果您只想要一个标准 可扩展 ListView ,我建议您查看示例:

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

  • ExpandableList1.java
  • ExpandableList2.java
  • ExpandableList3.java

如果您想要超过 2 级,请从此处继续阅读:

我以前没有这样做过,但我相信您要实现的是第 n 阶 exanpdablelistview。这里还有另一篇文章您可能会感兴趣:Multi level view: expandablelistview

来自此处的另一篇文章:https://stackoverflow.com/a/8352750/969325似乎您无法通过常规的可扩展 ListView 实现此目的,因此您必须:

  1. 从 scatch 制作您自己的可扩展 ListView 。
  2. 对前 2 个 lvls 使用 expandablelistview,并使用 linearlayout 等制作最后一个级别。
  3. 使用在 ScrollView 中分层的 View 制作所有内容。

关于android - 使用 expandablelistview 在 android 中的另一个组中动态创建组。,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12016700/

24 4 0
文章推荐: android - 从辅助模块获取应用程序上下文
文章推荐: javascript - 以编程方式打开