Как реализовать разбиение на страницы, используя библиотеку подкачки с RecyclerView внутри NestedScrollView - PullRequest
0 голосов
/ 07 января 2019

Я использую Библиотека подкачки для создания данных из веб-API и прекрасно работает с RecyclerView , который не внутри NestedScrollView . Но когда я помещаю RecyclerView в библиотеку подкачки NestedScrollView, запросы к данным бесконечно, поэтому подкачка не происходит, поскольку целые данные загружаются одновременно.

Вот как выглядит макет:

<androidx.core.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/frag_nested_scroll_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipToPadding="false"
android:scrollbars="none"
android:scrollingCache="true">

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal">

        <!--SOME OTHER LAYOUTS-->

    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:gravity="center_vertical"
        android:orientation="horizontal">

        <!--SOME OTHER LAYOUTS-->
    </LinearLayout>

    <androidx.recyclerview.widget.RecyclerView
        android:id="@+id/recycler_view"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:padding="@dimen/spacing_medium" />

</LinearLayout>

В деятельности:

    private fun getPosts(){
    val adapter = PostsAdapter {
        viewModel.retry()
    }
    recycler_view.adapter = adapter
    recycler_view.layoutManager = LinearLayoutManager(this)
    //Other codes .....
}

Как мне это решить?

...