【问题标题】:How to set an imageview with a picture from firebase storage如何使用来自 Firebase 存储的图片设置图像视图
【发布时间】:2019-07-22 19:43:34
【问题描述】:

我正在尝试检索从 Firebase 存储手动上传的图像,并将它们显示在应用程序的图像视图中。我在下面尝试了这种方法。我使用下面代码的原因是因为将来我想通过简单地删除数据库中的图像并将其替换为与以前相同名称的新图像来更改图像。例如,我的 firebase 中名为“A”的树的图像被删除并替换为名为“A”的狗的图像

private FirebaseStorage storage=FirebaseStorage.getInstance();
private ImageView mIm;
private StorageReference 

.....

mIm=(ImageView)findViewById(R.id.imageViewtiko);
    final long ONE_MEGABYTE=1024*1024;
    storageRef.getBytes(ONE_MEGABYTE).addOnSuccessListener(new OnSuccessListener<byte[]>() {
        @Override
        public void onSuccess(byte[] bytes) {
            Bitmap bitmap=BitmapFactory.decodeByteArray(bytes,0,bytes.length);
            mIm.setImageBitmap(bitmap);
        }
    });

应用程序在运行时不会崩溃,也不会出现错误消息,但它只是不显示图像。请帮忙

【问题讨论】:

    标签: firebase imageview firebase-storage


    【解决方案1】:

    我只是添加了一个 onFailureListener 并且效果很好

    【讨论】:

      猜你喜欢
      • 2019-05-06
      • 2023-03-13
      • 2022-01-04
      • 2017-12-22
      • 1970-01-01
      • 1970-01-01
      • 2019-07-01
      • 2020-12-04
      • 1970-01-01
      相关资源
      最近更新 更多