Skip to content

Instantly share code, notes, and snippets.

Created September 18, 2017 18:12
What would you like to do?
class WatchAdapter extends RecyclerView.Adapter<WatchAdapter.MyViewHolder> {
private Context context;
private List<Watch> watchList;
class MyViewHolder extends RecyclerView.ViewHolder {
TextView brand, color;
ImageView thumbnail;
MyViewHolder(View view) {
brand = (TextView) view.findViewById(;
color = (TextView) view.findViewById(;
thumbnail = (ImageView) view.findViewById(;
WatchAdapter(Context mContext, List<Watch> watchList) {
this.context = mContext;
this.watchList = watchList;
public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View itemView = LayoutInflater.from(parent.getContext())
.inflate(R.layout.watch_card, parent, false);
return new MyViewHolder(itemView);
public void onBindViewHolder(final MyViewHolder holder, int position) {
Watch watch = watchList.get(position);
public int getItemCount() {
return watchList.size();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment