Java 如何使用 Firebase 填充 RecyclerView 适配器
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/31110108/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to fill RecyclerView Adapter with Firebase
提问by Adem ?lhan
I made a lot of research, but I couldn't find any resource how to use Recycler View with Firebase
(or vice versa)
我做了很多研究,但我找不到任何资源如何使用 Recycler View Firebase
(反之亦然)
There is one Firebase list adapter which extends from BaseAdapter
. I found it in Firebase Chat application. Here is the FirebaseListAdapterclass. But the adapter which is used by RecyclerView needs to be extended from RecyclerView.Adapter
.
有一个 Firebase 列表适配器从BaseAdapter
. 我在Firebase Chat 应用程序中找到了它。这是FirebaseListAdapter类。但是 RecyclerView 使用的适配器需要从RecyclerView.Adapter
.
How did you overcome this problem? Do you have any suggestion?
你是如何克服这个问题的?你有什么建议吗?
采纳答案by Frank van Puffelen
For the moment you will have to provide your own implementation of the RecyclerView.Adapter.
目前,您必须提供自己的 RecyclerView.Adapter 实现。
You can use the FirebaseListAdapter for inspiration or roll your own.
您可以使用 FirebaseListAdapter 来获取灵感或自己动手。
Here's a chat app that uses a RecyclerView: https://github.com/thaleslima/Chat-Firebase/tree/master/app/src/main/java/com/gdgcampinas/chat_firebase
这是一个使用 RecyclerView 的聊天应用程序:https: //github.com/thaleslima/Chat-Firebase/tree/master/app/src/main/java/com/gdgcampinas/chat_firebase
Update
更新
There is now a library called FirebaseUIthat includes a FirebaseRecyclerAdapter
and much more. I highly recommend that you use that one in your apps or as the basis for an adapter that suits your needs.
现在有一个名为FirebaseUI的库,其中包含一个FirebaseRecyclerAdapter
等等。我强烈建议您在您的应用程序中使用它,或者作为适合您需求的适配器的基础。
回答by Hon
you can use the FirebaseUI-Android, it is developed by Firebase itself which is quite useful.
您可以使用FirebaseUI-Android,它是由 Firebase 自己开发的,非常有用。
The link shown as below.
链接如下图。
https://github.com/firebase/FirebaseUI-Android/blob/master/database/README.md
https://github.com/firebase/FirebaseUI-Android/blob/master/database/README.md