如何将图像从Firebase下载到ImageView

时间:2019-04-26 15:21:53

标签: android firebase

大家好,我想在imageview中设置Firebase中的图像,我已经尝试过由Google建议的代码,但是我对GlideApp有问题,并且图像不显示

// Reference to an image file in Cloud Storage
   StorageReference storageReference = FirebaseStorage.getInstance().getReference() 
// ImageView in your Activity
   ImageView imageView = findViewById(R.id.imageView);

// Download directly from StorageReference using Glide
// (See MyAppGlideModule for Loader registration)
   GlideApp.with(this /* context */)
    .load(storageReference)
    .into(imageView);

1 个答案:

答案 0 :(得分:0)

您需要提供Cloud storage内图像的路径,如下所示:

   storageReference.child(/some_images/path).getDownloadUrl().addOnSuccessListener(new OnSuccessListener<Uri>() {
                @Override
                public void onSuccess(Uri uri) {
                    Glide
                            .with(this) 
                            .load(uri) // pass the image url
                            .into(imageView); ed
                }
            });