Overview
官方链接:
https://developer.android.com/topic/libraries/architecture/paging/v3-overview
需要注意的是,Paging 库的组件在应用程序的三层中运行,Paging在三层的架构如下图:
- 存储库层
- ViewModel层
- 用户界面层
在三层的数据传递如下图:
方法/接口
官方链接:
https://developer.android.com/reference/androidx/paging/package-summary
版本查询
https://developer.android.com/jetpack/androidx/releases/paging
使用
基础官方教程(看这个即可)
https://developer.android.com/codelabs/android-paging-basics?hl=zh-cn#0
在Compose页面层的用法,看这里
https://developer.android.com/reference/kotlin/androidx/paging/compose/package-summary
给个示意代码:
LazyColumn(modifier = Modifier.fillMaxWidth().fillMaxHeight()){
itemsIndexed(collectAsLazyPagingItems.itemSnapshotList) { index, collect ->//每个item的展示
if (collect != null) {
Card(
modifier
.border(2.dp, color = Color.Black)
.height(100.dp)
.width(100.dp))
{
Text(text = collect.name)
}
}
}
}
官方教程2(补充)
https://developer.android.com/codelabs/android-paging?hl=zh-cn#0
注意: 要保证viewModel只能访问到Repository类,所以加入PagingSource类后,需要更新Repository类,使其加入XXXXPagingSource()
:
package com.example.android.codelabs.paging.data
import androidx.paging.PagingSource
class ArticleRepository {
fun articlePagingSource() = ArticlePagingSource()
}
- Android Compose Paging3 Pagingandroid compose paging3 paging paging3 recyclerview loadmore paging3功能 android compose banner android jetpack compose android jetpack compose动画 android compose tabrow pager android jetpack compose button navigation android compose jetpack_compose android jetpack compose