[null,null,["最后更新时间 (UTC):2025-07-30。"],[],[],null,["# Paging library overview\nPart of [Android Jetpack](/jetpack).\n============================================================\n\nThe Paging library helps you load and display pages of data from a larger\ndataset from local storage or over a network. This approach lets your app use\nboth network bandwidth and system resources more efficiently. The components of\nthe Paging library are designed to fit into the recommended [Android app\narchitecture](/jetpack/docs/guide), integrate cleanly with other\n[Jetpack](/jetpack) components, and provide first-class Kotlin support.\n\nBenefits of using the Paging library\n------------------------------------\n\nThe Paging library includes the following features:\n\n- In-memory caching for your paged data. This helps ensure that your app uses system resources efficiently while working with paged data.\n- Built-in request deduplication, which helps ensure that your app uses network bandwidth and system resources efficiently.\n- Configurable [`RecyclerView`](/reference/kotlin/androidx/recyclerview/widget/RecyclerView) adapters that automatically request data as the user scrolls toward the end of the loaded data.\n- First-class support for Kotlin coroutines and flows as well as [`LiveData`](/reference/kotlin/androidx/lifecycle/LiveData) and RxJava.\n- Built-in support for error handling, including refresh and retry capabilities.\n\nProvide feedback\n----------------\n\nYour feedback helps make Jetpack better. Let us know if you discover new issues\nor have ideas for improving this library. Check the\n[existing issues](https://issuetracker.google.com/issues?q=componentid:413106%20status:open)\nfor this library before you create a new one. You can add your vote to an\nexisting issue by clicking the star button.\n\n[Create a new issue](https://issuetracker.google.com/issues/new?component=413106&template=1096385)\n\nSee the [Issue Tracker\ndocumentation](https://developers.google.com/issue-tracker) for more\ninformation about submitting feedback.\n\nSetup\n-----\n\nTo import Paging components into your Android app, add the following\ndependencies to your app's `build.gradle` file: \n\n### Groovy\n\n```groovy\ndependencies {\n def paging_version = \"3.3.6\"\n\n implementation \"androidx.paging:paging-runtime:$paging_version\"\n\n // alternatively - without Android dependencies for tests\n testImplementation \"androidx.paging:paging-common:$paging_version\"\n\n // optional - RxJava2 support\n implementation \"androidx.paging:paging-rxjava2:$paging_version\"\n\n // optional - RxJava3 support\n implementation \"androidx.paging:paging-rxjava3:$paging_version\"\n\n // optional - Guava ListenableFuture support\n implementation \"androidx.paging:paging-guava:$paging_version\"\n\n // optional - Jetpack Compose integration\n implementation \"androidx.paging:paging-compose:3.4.0-alpha02\"\n}\n```\n\n### Kotlin\n\n```kotlin\ndependencies {\n val paging_version = \"3.3.6\"\n\n implementation(\"androidx.paging:paging-runtime:$paging_version\")\n\n // alternatively - without Android dependencies for tests\n testImplementation(\"androidx.paging:paging-common:$paging_version\")\n\n // optional - RxJava2 support\n implementation(\"androidx.paging:paging-rxjava2:$paging_version\")\n\n // optional - RxJava3 support\n implementation(\"androidx.paging:paging-rxjava3:$paging_version\")\n\n // optional - Guava ListenableFuture support\n implementation(\"androidx.paging:paging-guava:$paging_version\")\n\n // optional - Jetpack Compose integration\n implementation(\"androidx.paging:paging-compose:3.4.0-alpha02\")\n}\n```\n\nLibrary architecture\n--------------------\n\nThe Paging library's components operate in three\nlayers of your app:\n\n- The repository layer\n- The `ViewModel` layer\n- The UI layer\n\n**Figure 1.** An example of how the Paging library fits into your app architecture.\n\nThis section describes the Paging library components that operate at each layer\nand how they work together to load and display paged data.\n\n### Repository layer\n\nThe primary Paging library component in the repository layer is\n[`PagingSource`](/reference/kotlin/androidx/paging/PagingSource). Each\n`PagingSource` object defines a source of data and how to retrieve data from\nthat source. A `PagingSource` object can load data from any single source,\nincluding network sources and local databases.\n\nAnother Paging library component that you might use is\n[`RemoteMediator`](/reference/kotlin/androidx/paging/RemoteMediator). A\n`RemoteMediator` object handles paging from a layered data source, such as a\nnetwork data source with a local database cache.\n\n### ViewModel layer\n\nThe [`Pager`](/reference/kotlin/androidx/paging/Pager) component provides a\npublic API for constructing instances of `PagingData` that are exposed in\nreactive streams, based on a `PagingSource` object and a\n[`PagingConfig`](/reference/kotlin/androidx/paging/PagingConfig) configuration\nobject.\n\nThe component that connects the `ViewModel` layer to the UI is\n[`PagingData`](/reference/kotlin/androidx/paging/PagingData). A `PagingData`\nobject is a container for a snapshot of paginated data. It queries a\n[`PagingSource`](/reference/kotlin/androidx/paging/PagingSource) object and\nstores the result.\n\n### UI layer\n\nThe primary Paging library component in the UI layer is\n[`PagingDataAdapter`](/reference/kotlin/androidx/paging/PagingDataAdapter), a\n[`RecyclerView`](/reference/kotlin/androidx/recyclerview/widget/RecyclerView)\nadapter that handles paginated data.\n\nAlternatively, you can use the included\n[`AsyncPagingDataDiffer`](/reference/kotlin/androidx/paging/AsyncPagingDataDiffer)\ncomponent to build your own custom adapter.\n| **Note:** If your app uses [Compose](/jetpack/compose) for its UI, use the [`androidx.paging:paging-compose`](/reference/kotlin/androidx/paging/compose/package-summary) artifact to integrate Paging with your UI layer instead. To learn more, see the API documentation for [`collectAsLazyPagingItems()`](/reference/kotlin/androidx/paging/compose/package-summary#collectaslazypagingitems).\n\nAdditional resources\n--------------------\n\nTo learn more about the Paging library, see the following additional resources:\n\n### Codelabs\n\n- [Android Paging Basics codelab](https://developer.android.com/codelabs/android-paging-basics)\n- [Android Paging Advanced codelab](https://codelabs.developers.google.com/codelabs/android-paging)\n\nRecommended for you\n-------------------\n\n- Note: link text is displayed when JavaScript is off\n- [Load and display paged data](/topic/libraries/architecture/paging/v3-paged-data)\n- [Migrate to Paging 3](/topic/libraries/architecture/paging/v3-migration)\n- [Page from network and database](/topic/libraries/architecture/paging/v3-network-db)"]]