无论如何,用firebase的recyclerview适配器创建一个无尽的滚动? [英] Is there anyway to create an endless scroller with firebase's recyclerview adapter?

查看:211
本文介绍了无论如何,用firebase的recyclerview适配器创建一个无尽的滚动?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在搜索整个互联网,而有办法创建一个无尽的滚动,对于简单recyclerviews,没有任何的firebase recyclerview适配器。如果有人已经实施了这个,请帮助!

解决方案

我正面临同样的问题,并没有找到任何解决方案但是我实现了。不会称之为正确的解决方案,但它给了我所需的输出。



让我们举一个例子,我有一个Firebase数据库中的汽车列表,我想在我的应用程序中显示。在我的应用程序中,有一个按钮显示所有汽车,将我带到一个新的活动,我必须从我的Firebase数据库中显示所有汽车。



解决方案:首先,我尝试在我的第二个活动中加载Firebase数据,但随着数据的增加,RecyclerView开始了抖动。因此,不是在我的第二个活动中检索Firebase数据,而是在单击按钮(位于ArrayList中)时检索了我的FirstActivity中的Firebase数据。那么在完成数据检索之后,Intent被调用,并且将我的firebase数据的 Arraylist 作为Extra in Intent发送给secondActivity。然后,您可以检索您的 ArrayList 并将正常的Endless recyclerView逻辑应用于 ArrayList

另外一个我现在想到的问题是
如何检查Firebase是否完成检索数据?经过大量的研究,我发现这个)

Firebase事件不是按顺序执行,Value甚至总是最后执行,所以在 onClickListener 我有两个 EventListeners


  1. OnChildEventListener (太加载我的实际数据)
  2. addListenerForSingleValueEvent 所以现在在> addListenerForSingleValueEvent()里面写代码将会被执行到最后(
    $>作为额外的Arraylist的意图)

    我不知道这是否回答你的问题,但我希望这有助于。

    I've been searching all over the internet, while there are ways to create an endless scroller, for simple recyclerviews, there aren't any for the firebase recyclerview adapter. If anyone has implemented this, please help!

    解决方案

    I was facing the same problem, and didn't find any solution for that But i achieved it. Won't call it a right solution but it gave me the desired output.

    Lets take an example, i have a list of cars in my Firebase Database and i want to display that in my app. In my App, there is a button "Show All The Cars" which takes me to a new Activity where I have to display all the cars from my Firebase database.

    Solution: At first I tried to load the Firebase data in my Second Activity which worked fine. But as the data increased, the RecyclerView started Jittering. So instead of retrieving the Firebase data in my Second Activity, I retrieved the Firebase data in my FirstActivity when the button was clicked (in a ArrayList). then after the complete data is retrieved, Intent was called, and I sent the Arraylist with my firebase data to the secondActivity as an Extra in Intent.

    You can then retrieve your ArrayList and Apply the normal Endless recyclerView logic to the ArrayList.

    The Other question i think would come up right now is How to check if the Firebase is done retrieving data ? (Again After a huge amount of research I found this)

    Firebase events are not executed in sequence, the Value even is always executed last, So In my onClickListener i had two EventListeners

    1. OnChildEventListener (too load my actual data)
    2. addListenerForSingleValueEvent (this would be executed last)

    So now, writing code inside addListenerForSingleValueEvent() would be executed last (The Intent with Arraylist as an Extra)

    I don't know if this answered your Question, but I hope this helps.

    这篇关于无论如何,用firebase的recyclerview适配器创建一个无尽的滚动?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆