multiple recyclerviews?

Hardik Patel picture Hardik Patel · Dec 6, 2017 · Viewed 8.5k times · Source

I want to make my homepage with two row with recyclerview with data of books and the events which are display independent of each other how can i accomplish it I want to add event to the my code how can i do it?

MoviesAdapter.java

public class MoviesAdapter extends RecyclerView.Adapter<MoviesAdapter.MyViewHolder> {

private List<Movie> moviesList;
public Context context;

public class MyViewHolder extends RecyclerView.ViewHolder {
    public TextView title;
    public ImageView thumbnail;


    public MyViewHolder(View view) {
        super(view);
        title = (TextView) view.findViewById(R.id.title);
        thumbnail = (ImageView) view.findViewById(R.id.book);

    }
}//End of MyViewHolder class

public MoviesAdapter(List<Movie> moviesList) {
    this.moviesList = moviesList;
}

//display different items in the data set
@Override
public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
    View itemView = LayoutInflater.from(parent.getContext())
            .inflate(R.layout.movie_list_row, parent, false);

    return new MyViewHolder(itemView);
}

//display data at specified location
@Override
public void onBindViewHolder(MyViewHolder holder, int position) {

    holder.title.setText(moviesList.get(position).getTitle());

    holder.thumbnail.setImageResource(moviesList.get(position).getImage());
}

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

I want to make my page like this

enter image description here

Answer

Adrian K picture Adrian K · Dec 6, 2017

It should be fine to use a LinearLayout with 3 RecyclerViews in it and create an Adapter for each of them. Nested RecyclerViews would only make sense if you had a lot of categories.