[英]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.