【问题标题】:Group and child divider in ExpandableListViewExpandableListView 中的组和子分隔符
【发布时间】:2015-07-30 23:59:33
【问题描述】:

您好,我想在组行之间设置分隔线,但在子行之间不设置。我正在使用:

android:divider="#A8A8A8"
android:dividerHeight="5.0sp"

要获得组行之间的空间,但是孩子呢?我正在尝试使用android:childDivider="@null"android:childDivider="#00000000",但它不能正常工作。我也在组布局中使用 View 元素,但我认为这不是一个很好的解决方案。如果我想在儿童中使用与组中不同的分隔线,我的意思是不同的高度和颜色怎么办?是否可以在布局中没有 View 元素? 如果没有其他可能性,我可以在组行中使用 View 元素,但是在展开 listview 之后我应该在哪里隐藏它然后显示它?

【问题讨论】:

    标签: android android-listview expandablelistview


    【解决方案1】:

    所以我决定使用 View 元素来做到这一点,但有时它不会无缘无故地消失。我虽然可能是线程问题,但我尝试在 Ui 线程上运行它并没有帮助。这是我的代码,我也在使用 AnimatedExpandableListView https://github.com/idunnololz/AnimatedExpandableListView:

    expandableListView.setOnGroupClickListener(new ExpandableListView.OnGroupClickListener() {
      @Override
      public boolean onGroupClick(ExpandableListView parent, final View v, final int groupPosition, long id) {
        Boolean shouldExpand = (!expandableListView.isGroupExpanded(groupPosition));
        if (shouldExpand) {
          if (currentlyExpanded != -1) {
            expandableListView.collapseGroup(currentlyExpanded);
            View view = getViewByPosition(currentlyExpanded, expandableListView).findViewById(R.id.dummyView);
            if (view != null) {
              view.setVisibility(View.VISIBLE);
            }
          }
          expandableListView.expandGroupWithAnimation(groupPosition);
          smoothScrollToPositionFromTop(expandableListView, groupPosition);
          v.findViewById(R.id.dummyView).setVisibility(View.GONE);
          currentlyExpanded = groupPosition;
          return true;
        }
        v.findViewById(R.id.dummyView).setVisibility(View.VISIBLE);
        return false;
      }
    });
    

    【讨论】:

      猜你喜欢
      • 2011-03-15
      • 1970-01-01
      • 2018-06-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-04-21
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多