我有一个呈现项目列表的 RecyclerView (ParentRV)。每个子项 (ViewHolder) 都是一个 RecyclerView (ChildRV),它呈现一个项列表。
然后我实现了分页库来为 ChildRV 加载数据。问题是,在我将 loadInitial() 方法返回的结果更新到 PagedListAdapter 之后,分页库的 DataSource 不断调用 loadAfter() 方法。
请提供任何帮助!这是 ParentRV 和 ChildRV 的布局。
parent_layout.xml
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<androidx.coordinatorlayout.widget.CoordinatorLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/white">
<com.google.android.material.appbar.AppBarLayout
android:id="@+id/appBar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fitsSystemWindows="true">
// ....
</com.google.android.material.appbar.AppBarLayout>
<com.example.ecommerce.presentation.widget.RefreshLayout
android:id="@+id/refreshLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/sectionList"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clipToPadding="false" />
</com.example.ecommerce.presentation.widget.RefreshLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
</layout>
child_layout.xml
<layout xmlns:android="http://schemas.android.com/apk/res/android">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/productList"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</FrameLayout>
</layout>