Why I cant use the populateViewHolder override method?

拈花ヽ惹草 提交于 2019-11-26 11:55:33
Peter Haddad

The constructor of the Firebase...Adapter classes has changed in FirebaseUI version 3. Given this query:

Query query = FirebaseDatabase.getInstance()
    .getReference()
    .child("users")
    .equalTo(name);

If you're using a version 3 or higher, you use FirebaseRecyclerOptions:

 FirebaseRecyclerOptions<model_class_name> options =
            new FirebaseRecyclerOptions.Builder<model_class_name>()
                    .setQuery(query, model_class_name.class)
                    .build();

Then declare a FirebaseRecyclerAdapter:

FirebaseRecyclerAdapter adapter = new FirebaseRecyclerAdapter<Chat, ChatHolder>(options) {

add the variable options as above. It is the variable of the class FirebaseRecyclerOptions

Then to add items you have to use onBindViewHolder since its the latest version of firebase ui:

 @Override
protected void onBindViewHolder(Holder holder, int position, model_class_name model) {
    // Bind the class object to the holder
    // ...
}

For more info check this: https://github.com/firebase/FirebaseUI-Android/tree/master/database

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!