D
D
dimasik1002002018-03-05 19:13:24
Java
dimasik100200, 2018-03-05 19:13:24

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 onBindViewHolderwrite

holder.avatar.setImageDrawable(profiles.getCardImage());

gives an error message
setImageDrawable (android.graphics.drawable.Drawable) in ImageView cannot be applied to (int)

although in the recycler view model i setint
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

1 answer(s)
D
Denis Zagaevsky, 2018-03-05
@dimasik100200

setImageResource
Of course, getCardImage should return @DrawableRes.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question