如何将Firestore和存储中的图像加载到RecyclerView中?

我没有找到任何解决方案,仅针对实时数据库。我设法从Firestore中的文档中获取一个String并将其显示在RecyclerView中,我希望使用图像实现相同的效果。

在Firestore中的文档中,我有一个字段,其中图片链接(存储在存储中)保存为字符串。我知道我必须以某种方式使用毕加索来加载图像,但是我不知道该怎么做。

这是我的代码:

function AmazonImage = ({url,isAuthenticated}){
  return useLoadImage(url,isAuthenticated)
}
//using the wrapper
<AmazonImage url='url' isAuthenticated={isAuthenticated} />

这是我的适配器:

public class Prizes {

    private String text;
    private String image;


    public Prizes (){

    }

    public Prizes(String text,String image) {
        this.text = text;
        this.image = image;
    }
    public String getText() {
        return text;
    }
    public String getImage(){
        return image;
    }
}
yoyocom_33 回答:如何将Firestore和存储中的图像加载到RecyclerView中?

使用Picasso将图像从url加载到ImageView非常简单。

首先,在您的项目的build.gradle依赖项中添加以下行并同步该项目

implementation 'com.squareup.picasso:picasso:2.71828'

同步项目,并让gradle下载毕加索libaray。完成后,在onBindViewHolder类的PrizeGameAdapter中添加以下代码行

Picasso.get()
.load(model.getImage())
.into(holder.imageViewPrizeGame);

中提琴,它将为您服务。

本文链接:https://www.f2er.com/3042254.html

大家都在问