Last active
August 26, 2018 12:56
-
-
Save ashishrawat2911/f4eac830d0e44b735bcc524f42955418 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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