我想用RecyclerView创建我的两行主页
有了书籍数据和相互独立显示的事件,我如何才能完成它我想将事件添加到我的代码中我如何才能做到?
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();
}
}

我想把我的网页变成这样
android - 多个recyclerviews?-LMLPHP

最佳答案

使用一个包含3个recyclerview的linearlayout并为每个recyclerview创建一个适配器应该没问题。嵌套的recyclerviews只有在有很多类别的情况下才有意义。

关于android - 多个recyclerviews?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/47676517/

10-11 21:38