如何使用 Glide 将 Firebase 生成的 url 放入 ImageView? [英] How to place a Firebase generated url into an ImageView with Glide?
问题描述
因此,当我将图像上传到 Firebase Storage 时,getDownloadUrl()
方法会生成一个字符串,例如:com.google.android.gms.tasks.zzu@275cc4
So when I upload an image onto Firebase Storage, the getDownloadUrl()
method generates a string such as: com.google.android.gms.tasks.zzu@275cc4
现在我正在尝试将上传的图像放入ImageView
:
Now I'm trying to place the image uploaded into an ImageView
:
ImageView img;
img = v.findViewById(R.id.imgView);
Glide.with(getApplicationContext()).load("com.google.android.gms.tasks.zzu@275cc4").into(img);
这似乎无法加载图像.我尝试使用完整的 firebase url https://firebasestorage.googleapis.com/v0/.....
并且这有效,但我似乎无法找到生成它的方法上传图片?
This doesn't seem to load the image. I tried with the full firebase url https://firebasestorage.googleapis.com/v0/.....
and this worked, but I can't seem to find a method that generates this when I upload an image?
推荐答案
storageRef.child(path).getDownloadUrl().addOnSuccessListener(new OnSuccessListener<Uri>() {
@Override
public void onSuccess(Uri uri) {
Glide.with(getApplicationContext()).load(uri.toString()).into(img);
}
});
希望这对你有帮助.......祝你有美好的一天
Hope this will help you.......Have a nice day
这篇关于如何使用 Glide 将 Firebase 生成的 url 放入 ImageView?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!