简体   繁体   English

使用Glide时发生错误

[英]Error when using Glide

The app crashes when I try to load an image with Glide . 当我尝试使用Glide加载图像时,应用程序崩溃。

I have the following code: 我有以下代码:

.java: .java:

ImageButton home_ib1;

Glide.with(Home.this)
            .load(R.drawable.moviep_24_hours_to_live)
            .override(98, 155)
            .centerCrop()
            .placeholder(R.drawable.moviep_24_hours_to_live)
            .into(home_ib1);

.xml: .xml:

<ScrollView
   <RelativeLayout


<ImageButton
            android:id="@+id/home_ib1"
            android:layout_width="98dp"
            android:layout_height="155dp"
            android:layout_marginStart="16dp"
            android:layout_marginTop="155dp"
            android:background="@android:color/transparent"
            android:scaleType="fitCenter"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="parent" />

And when I try to run app, i got crash..(LogCat: You must pass in a non null View) (The image's resolution that i have to load is 175x276 PNG) 当我尝试运行应用程序时,我崩溃了。(LogCat:您必须传递非null视图)(我必须加载的图像分辨率为175x276 PNG)

ImageButton home_ib1;

Looks Like home_ib1 is null 看起来home_ib1为空

Just add 只需添加

home_ib1 = findViewById(R.id.home_ib1);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM