Answer the question
In order to leave comments, you need to log in
How to fix image display error in recyclerview (image just doesn't appear)?
There is a recycler view with several elements, however, when the application starts, only text is displayed, and the pictures disappear. When trying to onBindViewHolder
write
holder.avatar.setImageDrawable(profiles.getCardImage());
setImageDrawable (android.graphics.drawable.Drawable) in ImageView cannot be applied to (int)
int
public class CardViewObject {
private int cardAvatar;
private String cardName;
private String cardLocation;
public CardViewObject(int cardAvatar, String cardName, String cardLocation) {
this.cardAvatar = cardAvatar;
this.cardName = cardName;
this.cardLocation = cardLocation;
}
public int getCardAvatar() {
return cardAvatar;
}
public void setCardAvatar(int cardAvatar) {
this.cardAvatar = cardAvatar;
}
public String getCardName() {
return cardName;
}
public void setCardName(String cardName) {
this.cardName = cardName;
}
public String getCardLocation() {
return cardLocation;
}
public void setCardLocation(String cardLocation) {
this.cardLocation = cardLocation;
}
}
Что делать?
Answer the question
In order to leave comments, you need to log in
setImageResource
Of course, getCardImage should return @DrawableRes.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question