Android:多级 ExpandableListView 多次显示子项

马特戴维斯

Root, Parent, Child多亏了一些教程,我已经创建了一个 3 级 ( ) 自定义 ExpandableListView 和相关的适配器。我有显示故障Parent列表的水平,而RootChild级别正确显示。我发现该Parent级别将其视图复制 N 次,其中 N 是Parent中元素的数量

我要的是:佳能下的三类

我得到的是:佳能下的三个类别重复了3次

Root 等级:

@Override
public View getChildView(int groupPosition, int childPosition, boolean isLastChild, 
                         View convertView, ViewGroup parent) {

/* this list is the header of the Parent level, and I know it has the correct number of elements */
List<String> lensTypeList = listDataChild.get(_listDataHeader.get(groupPosition));

/* the Parent level of the ExpandableListView */
LensSecondLevel lensSecondLevel = new LensSecondLevel(ManageLensesActivity.this);

/* all params other than lensTypeList work correctly in the later levels */
lensSecondLevel.setAdapter(new SecondLevelListViewAdapter(ManageLensesActivity.this, lensTypeList, lensMap, lensPositionIndicesMap));

getChildrenCount(int groupPosition)无论创建Root了多少个子 ( Parent) 视图of level 每次都会返回正确的数字我不知道为什么getGroupView会被反复调用该Parent级别。

Parent 等级:

@Override
public Object getGroup(int groupPosition)
{
    /* _listDataHeader is the same ArrayList<String> lensTypeList from above */
    return this._listDataHeader.get(groupPosition);
}

您不应该将 anArrayList<String>作为第二级 ExpandableListView 的标头传递吗?如果我将第二级String作为标题传递给单个级别,我只能达到预期的结果,但这打破了我查找Child级别视图的逻辑,因为groupPosition一直0以来_listDataHeader.size() == 1

提前感谢您的任何帮助/建议。:)

马特戴维斯

在这里找到答案:https : //stackoverflow.com/a/35208411/5004391

我真的不明白为什么,但我必须对要返回getChildrenCount(int groupPosition)Root级别进行硬编码1,而不是实际的孩子数量。在我的应用程序的其他ExpandableListViews 中,我总是返回孩子的数量并且它按预期工作。

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

Android中的多级ExpandableListView

来自分类Dev

Android中带有CheckBoxes的多级ExpandableListView

来自分类Dev

Android中带有CheckBoxes的多级ExpandableListView

来自分类Dev

展开多级ExpandableListView的问题

来自分类Dev

展开多级ExpandableListView的问题

来自分类Dev

Android-ExpandableListView不显示任何内容

来自分类Dev

Android ExpandableListView 子项也没有 ViewHolder 相互依赖

来自分类Dev

在ExpandableListView中更新子项

来自分类Dev

Expandablelistview点击子项

来自分类Dev

Xamarin android 在 ExpandableListView 中显示自定义布局

来自分类Dev

ExpandableListView错误显示?

来自分类Dev

在ObtainView的Android ExpandableListView NullPointerException

来自分类Dev

Android ExpandableListView setGroupIndicator?

来自分类Dev

在ObtainView的Android ExpandableListView NullPointerException

来自分类Dev

android expandablelistview 使用 volley

来自分类Dev

Android ExpandableListView - setOnChildLongClickListener?

来自分类Dev

在ExpandableListview中获取特定子项的视图

来自分类Dev

ExpandableListView展开视图未显示

来自分类Dev

禁用ExpandableListView中的突出显示

来自分类Dev

类似于TreeView Android的ExpandableListview

来自分类Dev

android在Expandablelistview上添加徽章

来自分类Dev

带有按钮的Android ExpandableListView

来自分类Dev

ExpandableListView Android中的键顺序

来自分类Dev

Android ExpandableListView getChildView 弄乱了数据

来自分类Dev

尝试在Android中显示子视图时,ExpandableListView具有错误的groupPosition

来自分类Dev

expandablelistview的group元素上的多次单击事件

来自分类Dev

Android ExpandableListView如何保存展开/折叠状态?

来自分类Dev

Android:如何从ExpandableListView删除标题视图?

来自分类Dev

android expandablelistView setAdapter不明确

Related 相关文章

  1. 1

    Android中的多级ExpandableListView

  2. 2

    Android中带有CheckBoxes的多级ExpandableListView

  3. 3

    Android中带有CheckBoxes的多级ExpandableListView

  4. 4

    展开多级ExpandableListView的问题

  5. 5

    展开多级ExpandableListView的问题

  6. 6

    Android-ExpandableListView不显示任何内容

  7. 7

    Android ExpandableListView 子项也没有 ViewHolder 相互依赖

  8. 8

    在ExpandableListView中更新子项

  9. 9

    Expandablelistview点击子项

  10. 10

    Xamarin android 在 ExpandableListView 中显示自定义布局

  11. 11

    ExpandableListView错误显示?

  12. 12

    在ObtainView的Android ExpandableListView NullPointerException

  13. 13

    Android ExpandableListView setGroupIndicator?

  14. 14

    在ObtainView的Android ExpandableListView NullPointerException

  15. 15

    android expandablelistview 使用 volley

  16. 16

    Android ExpandableListView - setOnChildLongClickListener?

  17. 17

    在ExpandableListview中获取特定子项的视图

  18. 18

    ExpandableListView展开视图未显示

  19. 19

    禁用ExpandableListView中的突出显示

  20. 20

    类似于TreeView Android的ExpandableListview

  21. 21

    android在Expandablelistview上添加徽章

  22. 22

    带有按钮的Android ExpandableListView

  23. 23

    ExpandableListView Android中的键顺序

  24. 24

    Android ExpandableListView getChildView 弄乱了数据

  25. 25

    尝试在Android中显示子视图时,ExpandableListView具有错误的groupPosition

  26. 26

    expandablelistview的group元素上的多次单击事件

  27. 27

    Android ExpandableListView如何保存展开/折叠状态?

  28. 28

    Android:如何从ExpandableListView删除标题视图?

  29. 29

    android expandablelistView setAdapter不明确

热门标签

归档