微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

如果 RecyclerviewItem 设置为隐藏,则 SwipeRefresh 布局不起作用

如何解决如果 RecyclerviewItem 设置为隐藏,则 SwipeRefresh 布局不起作用

我在我的 swiperefreshlayout 中使用了两个 recycerview一个用于空数据视图,一个用于 Recyclerview,我需要在 onBindViewHolder 方法中有条件地隐藏一些项目,问题是如果项目没有隐藏swiperefreshlayout 工作没有问题,但当我根据条件隐藏项目时,它不起作用

下面是我的布局文件

  <androidx.swiperefreshlayout.widget.SwipeRefreshLayout
     android:id="@+id/swipe_layoutforemptyview"
     android:layout_width="match_parent"
     android:layout_height="match_parent"
    >

    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:fillViewport="true">
        <TextView
            android:id="@+id/tvEmptyView"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:gravity="center"
            android:visibility="gone"
            android:text="No Data Available" />
    </ScrollView>
   </androidx.swiperefreshlayout.widget.SwipeRefreshLayout>

    <androidx.swiperefreshlayout.widget.SwipeRefreshLayout
        android:id="@+id/swipe_layout"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_marginTop="80dp">

    <androidx.recyclerview.widget.RecyclerView
        android:id="@+id/rv_questions"
        android:layout_width="fill_parent"
        android:layout_height="match_parent"
        android:paddingRight="10dp"
        android:paddingBottom="20dp" />

    </androidx.swiperefreshlayout.widget.SwipeRefreshLayout>

在我的 onBindViewHolder 下面我根据条件隐藏项目

 if(singletoneClass_saveposition.getInstance().getData()!=null && singletoneClass_saveposition.getInstance().getData().equals("1")){
            
          if(list.get(position).getSaved_bookid()==null){
                  holder.item_layout.setLayoutParams(new RecyclerView.LayoutParams(0,0));
                  swipLayout.setVisibility(View.VISIBLE);
                  swipLayout_emptyview.setVisibility(View.GONE);
           }
  }

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。