如何将Firebase从最后一项分到第一个? [英] How to paginate firebase from the last items to the first?
问题描述
我正在尝试使Firebase分页正常工作,但我想先使用最新的项目,然后再使用稍旧的项目,我尝试使用此方法,但似乎无法获得新的值,并不断传递相同的值...我正在通过到endAt的字符串ID,即路径Projects> projectId> moreinfo
I am trying to get firebase pagination working but I want the newest items first and then the ones slightly older, I tried to work with this but cannot seem to get new values, keeps passing the same ones...I am passing the String Id to endAt which is the path Projects > projectId > moreinfo
mDatabase.child("projects").orderByChild("viewCount").limitToLast(25).endAt(offSet.get("first")).addValueEventListener(new ValueEventListener() {
我试图将其切换为startAt,但我什至没有得到结果……任何想法?
I tried switching it to startAt and I do not even get results... any ideas?
推荐答案
偏移量必须与用于orderByChild的键相同-这就是为什么它不起作用的原因,因此更改了HashMap的此endAt(offSet.get("first"))
值(用于viewCount)
The offset had to be the same key used for orderByChild - that is why it did not work, so changed this endAt(offSet.get("first"))
value of the HashMap used to viewCount
这篇关于如何将Firebase从最后一项分到第一个?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!