问题描述
我有一个 FirebaseRecyclerAdapter
,我不想继续更新 RecyclerView
。这是因为我拥有它,所以它根据它们在数据库中有多少视图来填充视图。问题是,如果其他人查看项目,您在应用程序中看到的列表将保持更改顺序。
有没有办法阻止回收站适配器不断的监听数据的变化,还是需要另外的方法呢?
I have a FirebaseRecyclerAdapter
which I do not want to keep updating the RecyclerView
. This is because I have it so it populates the view with items based on how many 'views' they have in the database. The problem is, if other people view the items, the list you see in the app will keep changing order.Is there a way to stop the recycler adapter from constantly listening for data changes or will I have to go about this another way?
,谢谢。
推荐答案
FirebaseUI中的适配器实时绑定到您构建它们的Query / DatabaseReference中的数据。无法在适配器中关闭此功能。
The adapters in FirebaseUI are live-bound to the data at the Query/DatabaseReference that you construct them with. There is no way to turn this behavior off in the adapter.
但是,您可以轻松创建填充的 ValueEventListener
一个静态的 List< T>
,并将其提供给 ArrayAdapter
。
But you can easily create a ValueEventListener
that populates a static List<T>
and feeds that into an ArrayAdapter
.
这篇关于Firebase的android如何防止FirebaseRecyclerAdapter自动更新?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!