[英]Error when using Glide
当我尝试使用Glide加载图像时,应用程序崩溃。
我有以下代码:
.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:
<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" />
当我尝试运行应用程序时,我崩溃了。(LogCat:您必须传递非null视图)(我必须加载的图像分辨率为175x276 PNG)
ImageButton home_ib1;
看起来home_ib1为空
只需添加
home_ib1 = findViewById(R.id.home_ib1);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.