如何使用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网址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屋!