Skip to content

Instantly share code, notes, and snippets.

@ashishrawat2911
Last active August 26, 2018 12:56
Show Gist options
  • Save ashishrawat2911/f4eac830d0e44b735bcc524f42955418 to your computer and use it in GitHub Desktop.
Save ashishrawat2911/f4eac830d0e44b735bcc524f42955418 to your computer and use it in GitHub Desktop.
public class PhotographerAdapter extends RecyclerView.Adapter<PhotographerAdapter.PhotoViewHolder> {
Context mCtx;
List<Photographer> photographersList;
public PhotographerAdapter(Context mCtx, List<Photographer> photographersList) {
this.mCtx = mCtx;
this.photographersList= photographersList;
}
@NonNull
@Override
public PhotoViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
View view = LayoutInflater.from(mCtx).inflate(R.layout.recyclerview_layout, parent, false);
return new PhotoViewHolder(view);
}
@Override
public void onBindViewHolder(@NonNull PhotographerViewHolder holder, int position) {
Photographer photographer= photographersList.get(position);
Glide.with(mCtx)
.load(photographer.getImageurl())
.into(holder.imageView);
holder.textView.setText(photo.getName());
}
@Override
public int getItemCount() {
return photographersList.size();
}
class PhotoViewHolder extends RecyclerView.ViewHolder {
ImageView imageView;
TextView textView;
public PhotoViewHolder(View itemView) {
super(itemView);
imageView = itemView.findViewById(R.id.imageView);
textView = itemView.findViewById(R.id.textView);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment