Firebaserecycleradapter

Firebaserecycleradapter

本文介绍了FirebaseRecyclerAdapter无法应用于的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

代码:

@Override
    public void onStart() {
        super.onStart();

        recyclerViewadapter=new FirebaseRecyclerAdapter<RecycleModel, UserViewHolder>(RecycleModel.class, R.layout.recycler_model, UserViewHolder.class, muserDB)
        {
            @Override
            protected void onBindViewHolder(@NonNull UserViewHolder holder, int position, @NonNull RecycleModel model) {

            }

            @NonNull
            @Override
            public UserViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
                return null;
            }
        };

FirebaseRecyclerAdapter出现错误

我的gradle文件应用级别

推荐答案

要解决此问题,请使用以下代码:

To solve this, please use the following code:

FirebaseRecyclerOptions<RecycleModel> firebaseRecyclerOptions = new FirebaseRecyclerOptions.Builder<RecycleModel>()
    .setQuery(muserDB, RecycleModel.class)
    .build();

recyclerViewadapter=new FirebaseRecyclerAdapter<RecycleModel, UserViewHolder>(firebaseRecyclerOptions) {
    @Override
    protected void onBindViewHolder(@NonNull UserViewHolder holder, int position, @NonNull RecycleModel model) {
            // set the model to the holder
    }

    @NonNull
    @Override
    public UserViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        return null;
    }
};

FirebaseRecyclerAdapter类在构造器中将最后一个版本的参数作为FirebaseRecyclerOptions对象的参数,而不再是这四个参数.

FirebaseRecyclerAdapter class takes in the last version as an argument in the constructor a FirebaseRecyclerOptions object not those 4 arguments anymore.

如果您有兴趣,请 是推荐的方法,您可以从Firebase Realtime数据库中检索数据,并使用FirebaseRecyclerAdapterRecyclerView中将其显示.

If you are interested, this is a recommended way in which you can retrieve data from a Firebase Realtime database and display it in a RecyclerView using FirebaseRecyclerAdapter.

这篇关于FirebaseRecyclerAdapter无法应用于的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-14 07:25