0Pricing
Android Academy · Lesson

Paging in Compose Lists

Render paged data with LazyColumn.

Rendering Paged Data in Compose

The data layer hands you a Flow<PagingData<Article>>. The paging-compose library turns that flow into something a LazyColumn can render, complete with on-demand loading as the user scrolls.

The key bridge is collectAsLazyPagingItems().

collectAsLazyPagingItems

Call collectAsLazyPagingItems() on the flow inside a composable. It returns a LazyPagingItems object that tracks the loaded items and load states, recomposing the UI as pages arrive.

import androidx.paging.compose.collectAsLazyPagingItems

@Composable
fun ArticleScreen(viewModel: ArticleViewModel) {
    val articles = viewModel.articles.collectAsLazyPagingItems()
    ArticleList(articles)
}

All lessons in this course

  1. Why Paging
  2. PagingSource and Pager
  3. Paging in Compose Lists
  4. RemoteMediator and Caching
← Back to Android Academy