【问题标题】:Unable to display images from Firebase(using glide)无法显示来自 Firebase 的图像(使用滑行)
【发布时间】:2017-08-17 01:37:03
【问题描述】:

在添加材料设计之前它可以工作,但是在改变我的布局之后(关于 imageview 没有任何改变)我无法显示图像。

public class DownloadFile extends AppCompatActivity {

    ImageView imageview;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_download_file);
        Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
        setSupportActionBar(toolbar);

        FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
        fab.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Snackbar.make(view, "Wait for the action", Snackbar.LENGTH_LONG)
                        .setAction("Action", null).show();
                yukle();
            }
        });


    }

    public void yukle(){
        FirebaseStorage storage = FirebaseStorage.getInstance();
        StorageReference storageRef = storage.getReference();
        StorageReference riversRef = storageRef.child("images/pic.jpg");

        imageview=(ImageView)findViewById(R.id.imageView);


        Glide.with(this)
                .using(new FirebaseImageLoader())
                .load(riversRef)
                .into(imageview);
    }
}

我收到以下错误

03-24 07:41:22.284 22900-22900/com.furkan.profil E/AndroidRuntime: FATAL EXCEPTION: main
                                                               Process: com.furkan.profil, PID: 22900
                                                               java.lang.IllegalArgumentException: You must pass in a non null View
                                                                   at com.bumptech.glide.GenericRequestBuilder.into(GenericRequestBuilder.java:678)
                                                                   at com.bumptech.glide.DrawableRequestBuilder.into(DrawableRequestBuilder.java:448)
                                                                   at com.furkan.profil.DownloadFile.yukle(DownloadFile.java:58)
                                                                   at com.furkan.profil.DownloadFile$1.onClick(DownloadFile.java:40)
                                                                   at android.view.View.performClick(View.java:5198)
                                                                   at android.view.View$PerformClick.run(View.java:21147)
                                                                   at android.os.Handler.handleCallback(Handler.java:739)
                                                                   at android.os.Handler.dispatchMessage(Handler.java:95)
                                                                   at android.os.Looper.loop(Looper.java:148)
                                                                   at android.app.ActivityThread.main(ActivityThread.java:5417)
                                                                   at java.lang.reflect.Method.invoke(Native Method)
                                                                   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
                                                                   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) 
03-24 07:41:30.213 22900-22994/com.furkan.profil W/DynamiteModule: Local module descriptor class for com.google.firebase.auth not found.

在 Firebase 这边是我的规则

service firebase.storage {
  match /b/{bucket}/o {
    match /{allPaths=**} {
       allow read: if true;
       allow write: if true;
    }
  }
}

【问题讨论】:

    标签: android firebase firebase-storage android-glide


    【解决方案1】:

    您的堆栈跟踪表明您在 Glide 中传递的图像视图为空。所以你在findViewById中设置为参数的id一定是错误的。确保您传递正确的 id,否则请发布您的 xml,以便我们获得更多信息。

    【讨论】:

    • 谢谢我解决了这个问题。问题是我的 imageView 没有任何 id。我给了他身份证,问题就解决了。再次感谢。
    【解决方案2】:

    把这条线放在你的 onCreate 上

    imageview=(ImageView)findViewById(R.id.imageView);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-09-28
      • 2021-07-23
      • 2021-09-11
      • 2018-07-14
      • 1970-01-01
      • 1970-01-01
      • 2018-05-25
      • 1970-01-01
      相关资源
      最近更新 更多