我阅读了Firestore文档和互联网上所有关于Firestore分页的文章(Stackoverflow),但没有成功。我尝试在文档中实现完全相同的代码,但是什么也没有发生。我有一个基本的数据库与项目(超过1250或更多),我想逐步得到他们。通过滚动加载15个项目(到数据库中的最后一个项目)。
如果使用文档代码:
// Construct query for first 25 cities, ordered by population
Query first = db.collection("cities")
.orderBy("population")
.limit(25);
first.get()
.addOnSuccessListener(new OnSuccessListener<QuerySnapshot>() {
@Override
public void onSuccess(QuerySnapshot documentSnapshots) {
// ...
// Get the last visible document
DocumentSnapshot lastVisible = documentSnapshots.getDocuments()
.get(documentSnapshots.size() -1);
// Construct a new query starting at this document,
// get the next 25 cities.
Query next = db.collection("cities")
.orderBy("population")
.startAfter(lastVisible)
.limit(25);
// Use the query for pagination
// ...
}
});
怎么办?文档中没有太多的细节。
PS:我需要在用户滚动时使用回收器视图(而不是列表视图)。谢谢
https://stackoverflow.com/questions/50741958
复制相似问题