How to get a context in a recycler view adapter

后端 未结 12 1434
一向
一向 2020-12-02 06:12

I\'m trying to use picasso library to be able to load url to imageView, but I\'m not able to get the context to use the picasso library correctly.



        
12条回答
  •  悲&欢浪女
    2020-12-02 06:48

    First globally declare

    Context mContext;

    pass context with the constructor, by modifying it.

    public FeedAdapter(List myDataset, Context context) {
        mDataset = myDataset;
        this.mContext = context;
    }
    

    then use the mContext whereever you need it

提交回复
热议问题