0
            (Blog.class,R.layout.venue_row,BlogViewHolder.class,mDatabase) {

This line in onStart () showing error. Here I posted the screenshot of error message. Please check this once.

Error comes in the Activity.java file onStart() {...} (Blog.class,R.layout.venue_row,BlogViewHolder.class,mDatabase) {

Activity.java

package com.cornicore.icccricketworldcup2019;

import android.content.Context;
import android.os.Build;
import android.support.annotation.NonNull;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.view.ViewGroup;
import android.webkit.WebChromeClient;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.ImageView;
import android.widget.ProgressBar;
import android.widget.TextView;

import com.firebase.ui.database.FirebaseRecyclerAdapter;
import com.google.firebase.database.DatabaseReference;
import com.google.firebase.database.FirebaseDatabase;
import com.squareup.picasso.Picasso;
public class VenuesActivity extends AppCompatActivity {

    private RecyclerView mBlogList;
    private DatabaseReference mDatabase;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_venues);


        mDatabase = FirebaseDatabase.getInstance().getReference().child("Venues");
        mDatabase.keepSynced(true);
        mBlogList = (RecyclerView) findViewById(R.id.myrecyclerview);
        mBlogList.setHasFixedSize(true);
        mBlogList.setLayoutManager(new LinearLayoutManager(this));



    }

    @Override
    protected void onStart() {
        super.onStart();
        FirebaseRecyclerAdapter<Blog,BlogViewHolder,>firebaseRecyclerAdapter = new FirebaseRecyclerAdapter<Blog, BlogViewHolder>
                (Blog.class,R.layout.venue_row,BlogViewHolder.class,mDatabase) {
            @Override
            protected void onBindViewHolder(@NonNull BlogViewHolder holder, int position, @NonNull Blog model) {

            }

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

        mBlogList.setAdapter(firebaseRecyclerAdapter);

    }

    public static class BlogViewHolder extends RecyclerView.ViewHolder{
        View mView;
        public BlogViewHolder(View itemView){
            super(itemView);
            mView = itemView;
        }
        public void setTitle(String title){
            TextView post_title = (TextView) mView.findViewById(R.id.post_title);
            post_title.setText(title);
        }
        public void setDesc(String desc){
            TextView post_desc = (TextView) mView.findViewById(R.id.post_desc);
            post_desc.setText(desc);
        }
        public void setImage(Context ctx, String image){
            ImageView post_Image = (ImageView) mView.findViewById(R.id.post_image);
            Picasso.with(ctx).load(image).into(post_Image);
        }
    }

}

activity.xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".VenuesActivity">

    <android.support.v7.widget.RecyclerView
        android:id="@+id/myrecyclerview"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

    </android.support.v7.widget.RecyclerView>

</RelativeLayout>

Blog.java

package com.cornicore.icccricketworldcup2019;

public class Blog {

    private String title;
    private String desc;
    private String image;

    public Blog(String title, String desc, String image) {
        this.title = title;
        this.desc = desc;
        this.image = image;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getDesc() {
        return desc;
    }

    public void setDesc(String desc) {
        this.desc = desc;
    }

    public String getImage() {
        return image;
    }

    public void setImage(String image) {
        this.image = image;
    }
    public Blog(){

    }

}

venue_row.xml (showing recyclerview as cardview)

<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.CardView 
xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:orientation="vertical"
    android:layout_margin="7dp"
    app:cardCornerRadius="12dp"
    android:elevation="90dp">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="248dp"
        android:orientation="vertical"
        android:background="#121111">

        <ImageView
            android:id="@+id/post_image"
            android:layout_width="match_parent"
            android:layout_height="180dp"
            android:scaleType="centerCrop"/>

        <TextView
            android:id="@+id/post_title"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:textSize="20dp"
            android:text="POST TITLE"
            android:textColor="#fff"/>

        <TextView
            android:id="@+id/post_desc"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="POST DESC"
            android:textColor="#fff"/>


    </LinearLayout>



</android.support.v7.widget.CardView>
Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
Badal Kumar
  • 47
  • 2
  • 8
  • Maybe you should take a reference of this answer on stack overflow,https://stackoverflow.com/questions/47091837/firebaserecycleradapter-cannot-be-applied-to-firebaserecycleradapter – bindal May 21 '18 at 12:11

4 Answers4

1

Check the documentation here: FirebaseUI-Readme

They have changed the way the FirebaseRecyclerAdapter is setup. Now you need to use FirebaseRecyclerOptions to configure your FirebaseRecyclerAdapter

Cody W.
  • 376
  • 2
  • 6
0

You are getting that error because you are passing to the constructor a wrong number and a wrong type of arguments. In order to make it work, you need to pass as an argument a FirebaseRecyclerOptions object. A constructor with 4 arguments was needed in an earlier version of the Firebase-UI library. See here official documentation.

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

Alex Mamo
  • 130,605
  • 17
  • 163
  • 193
  • can you please help me to remove this error? I checked the link but all are same as i write – Badal Kumar May 21 '18 at 12:45
  • It is not. Please follow the exact stept from my answer at this [post](https://stackoverflow.com/questions/49383687/how-can-i-retrieve-data-from-firebase-to-my-adapter/49384849). See that the FirebaseRecyclerAdapter is instantiated using the `FirebaseRecyclerOptions` object. – Alex Mamo May 21 '18 at 12:48
  • Is there everything alright? Have you solved the issue? – Alex Mamo May 22 '18 at 07:05
0

Remove this Comma from your code in your onStart method

 FirebaseRecyclerAdapter<Blog,BlogViewHolder,>firebaseRecyclerAdapter
                                            ^
Nikunj Paradva
  • 15,332
  • 5
  • 54
  • 65
0

make adapter like below code ..

public class RecyclerViewAdpater extends RecyclerView.Adapter<RecyclerViewAdpater.ItemViewHolder> {
List<String> mStringList = new ArrayList<>();// hear you can pass any pojo class object.
Context mContext;

public RecyclerViewAdpater(List<String> mStringList, Context mContext) {
    this.mStringList = mStringList;
    this.mContext = mContext;
}

@Override
public ItemViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
    View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.activity_main, parent, false);
    return new ItemViewHolder(view);
}

@Override
public void onBindViewHolder(ItemViewHolder holder, int position) {
    // below code handle click event on recycler view item.
    String data=mStringList.get(position);
    holder.textView.setText(data);
}

@Override
public int getItemCount() {
    return mStringList.size();
}

public class ItemViewHolder extends RecyclerView.ViewHolder {
    TextView textView;

    public ItemViewHolder(View itemView) {
        super(itemView);
    }
}
}

then after in main activity getting your data then after call below code..

        RecyclerViewAdpater recyclerViewAdpater=new RecyclerViewAdpater(this,stringlist);
    recyclerView.setLayoutManager(new LinearLayoutManager(this));
    recyclerView.setAdapter(recyclerViewAdpater);
    recyclerViewAdpater.notifyDataSetChanged();

make sure passing your list of data is not empty.