如何从recyclerview中的Firebase数据库中从下到上检索数据,或者如何在Firebase中的数据库顶部添加数据? [英] How to retrieve data from bottom to top from Firebase database in recyclerview or how to add data at the top of database in Firebase?
问题描述
<所以建议我可以帮助我从底部到顶部检索数据的东西,或者我可以上传到我的数据库数组的顶部。提前致谢。请帮助我。
有几种方法可以做到这一点。
第一: 实现 FirebaseUI ,然后执行以下操作: 第二: 我更喜欢这种方式,特别是如果您计划在将来实现GridLayoutManager。注意,GridLayoutManager不支持 I m developing an app with Firebase database. I'm receiving data and uploading it there is no problem in that, but I want to add my data on the top of database array, not at the bottom of database array. So suggest me something which can help me to retrieve the data from bottom to the top or I can upload it to the top of my database array. Thanks in advance. Please help me out. There's a couple ways to do this. First: Implement FirebaseUI and then do the following: Second: I prefer this way, especially if you plan to implement a GridLayoutManager in the future. Note, GridLayoutManager does not support In your RecyclerViewAdapter
这篇关于如何从recyclerview中的Firebase数据库中从下到上检索数据,或者如何在Firebase中的数据库顶部添加数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
LinearLayoutManager layoutManager = new LinearLayoutManager(getActivity());
layoutManager.setReverseLayout(true);
layoutManager.setStackFromEnd(true);
recyclerView.setLayoutManager(layoutManager)
setStackFromEnd();
。以下将允许您在AdapterView中反转任何数据。
$ b $ p在您的RecyclerViewAdapter中
$ $ $ $ $ @Override
public Item getItem(int pos){
return super.getItem(getCount() - 1 - pos);
}
LinearLayoutManager layoutManager = new LinearLayoutManager(getActivity());
layoutManager.setReverseLayout(true);
layoutManager.setStackFromEnd(true);
recyclerView.setLayoutManager(layoutManager)
setStackFromEnd();
. The below will allow you to reverse any data in an `AdapterView.@Override
public Item getItem(int pos) {
return super.getItem(getCount() - 1 - pos);
}