Hey i m working on an application where i have list of image saving in firebase firestore now in my recyclerview i want only single image out of multiple images now when i am trying to retrive data everything is showing except the images how can i get that??
this is how i am trying to set the single image in recyclerview
@Override
public void onBindViewHolder(@NonNull WishlistViewholder holder, int position) {
holder.name.setText(wishlist_models.get(position).getName());
holder.email.setText(wishlist_models.get(position).getEmail());
Glide.with(context)
.load(wishlist_models.get(position).getImage())
.fitCenter()
.into(holder.wishlist_image);
}
firebase database
model class
public class Wishlist_Model {
String image;
String name;
String email;
String delete;
List<String> images;
public Wishlist_Model() {
}
public Wishlist_Model(String image, String name, String email, String delete, List<String> images) {
this.image = image;
this.name = name;
this.email = email;
this.delete = delete;
this.image = image;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public String getDelete() {
return delete;
}
public void setDelete(String delete) {
this.delete = delete;
}
public List<String> getImages() {
return images;
}
public void setImages(List<String> images) {
this.images = images;
}
}
CodePudding user response:
Try this -
@Override
public void onBindViewHolder(@NonNull WishlistViewholder holder, int position) {
holder.name.setText(wishlist_models.get(position).getName());
holder.email.setText(wishlist_models.get(position).getEmail());
if(wishlist_models.get(position).getImage()!=null && wishlist_models.get(position).getImage().size()>0) {
Glide.with(context)
.load(wishlist_models.get(position).getImage().get(0))
.fitCenter()
.into(holder.wishlist_image);
}
}