Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
public class RecyclerviewAdapter extends RecyclerView.Adapter<RecyclerviewAdapter.MyViewHolder> {
private List<Movie> movieList;
RecyclerviewAdapter(List<Movie> movieList){
this.movieList = movieList;
}
@Override
public RecyclerviewAdapter.MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.recyclerview_adapter_layout,parent,false);
return new MyViewHolder(view);
}
@Override
public void onBindViewHolder(RecyclerviewAdapter.MyViewHolder holder, int position) {
holder.title.setText(movieList.get(position).getTitle());
holder.desc.setText(movieList.get(position).getDesc());
}
@Override
public int getItemCount() {
return movieList.size();
}
public class MyViewHolder extends RecyclerView.ViewHolder {
@BindView(R.id.textViewTitle)
TextView title;
@BindView(R.id.textViewDesc) TextView desc;
public MyViewHolder(View itemView) {
super(itemView);
ButterKnife.bind(this,itemView);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.