William Hodges
William Hodges

Reputation: 681

Issue with FirebaseUI and FirebaseRecyclerAdapater

So I have the following gist that I'm trying to use the FirebaseRecyclerAdapater:

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

        FirebaseRecyclerAdapter<String, FSViewHolder> adapter = new FirebaseRecyclerAdapter<String, FSViewHolder>(
                String.class,
                android.R.layout.two_line_list_item,
                FSViewHolder.class,
                fsRef
        ) {

            @Override
            protected void populateViewHolder(FSViewHolder viewHolder, String model, int position) {

            }
        };

    }

    public static class FSViewHolder extends RecyclerView.ViewHolder {
        TextView fsText;

        public FSViewHolder(View v) {
            super(v);
            fsText = (TextView) v.findViewById(android.R.id.text1);
        }
}

When I run the app in the studio i get an error message that says this:

Error:(88, 65) error: no suitable constructor found for FirebaseRecyclerAdapter(Class,int,Class,Firebase) constructor FirebaseRecyclerAdapter.FirebaseRecyclerAdapter(Class,int,Class,Query) is not applicable (argument mismatch; Firebase cannot be converted to Query) constructor FirebaseRecyclerAdapter.FirebaseRecyclerAdapter(Class,int,Class,DatabaseReference) is not applicable (argument mismatch; Firebase cannot be converted to DatabaseReference)

I'm really confused on what is going on. Can anyone tell me what I'm doing wrong?

Upvotes: 1

Views: 809

Answers (1)

niraj
niraj

Reputation: 18208

The type of fsRef seems not to be right. The super constructor of FirebaseRecyclerAdapter expects DatabaseReference whereas fsRef is of Firebase. I think it has to be of something of FirebaseDatabase.getInstance().getReference(). The link may be helpful firebase.google.com/docs/database/android/retrieve-data

Upvotes: 2

Related Questions