Android 首次使用Glide加载时,Imageview没有图像

Android 首次使用Glide加载时,Imageview没有图像,android,android-recyclerview,android-glide,httpexception,Android,Android Recyclerview,Android Glide,Httpexception,我正在使用加载图像,我的应用程序遇到错误: I/Glide: Root cause (1 of 1) com.bumptech.glide.load.HttpException: Not Found at com.bumptech.glide.integration.okhttp3.OkHttpStreamFetcher.onResponse(OkHttpStreamFetcher.java:73) at okhttp3.RealCall$AsyncCall.execute(Re

我正在使用加载图像,我的应用程序遇到错误:

I/Glide: Root cause (1 of 1) com.bumptech.glide.load.HttpException: Not Found
    at com.bumptech.glide.integration.okhttp3.OkHttpStreamFetcher.onResponse(OkHttpStreamFetcher.java:73)
    at okhttp3.RealCall$AsyncCall.execute(RealCall.java:206)
    at okhttp3.internal.NamedRunnable.run(NamedRunnable.java:32)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
    at java.lang.Thread.run(Thread.java:764)
第一次加载时会发生这种情况,但当我再次加载时,图像现在会出现

我正在从我的
RecyclerView
适配器加载图像,如下所示:

class MyRecyclerViewAdapter(private val glideApp: GlideRequests): RecyclerView.Adapter<MyRecyclerViewAdapter.ViewHolder>() {
    override fun onBindViewHolder(holder: ViewHolder, position: Int) {
        //... some stuff
        // Set a data
        glideApp.asBitmap()
            .load(img_url)
            .into(holder.itemView.ivImageHolder)
        // Set a data
    }
}
类MyRecycleServiceAdapter(私有val glideApp:GlideRequests):RecycleView.Adapter(){
覆盖BindViewHolder(holder:ViewHolder,位置:Int){
//…一些东西
//设置一个数据集
glideApp.asBitmap()
.load(img_url)
.into(holder.itemView.ivImageHolder)
//设置一个数据集
}
}
感谢您的帮助。

试试这个

私有列表myURL=

@Override
public void onBindViewHolder(ViewHolder viewHolder, int position) {
  ImageView imageView = ((MyViewHolder) viewHolder).imageView;
  String currentUrl = myUrls.get(position);

  Glide.with(fragment)
    .load(currentUrl)
    .override(imageWidthPixels, imageHeightPixels)
    .into(imageView);
}
试试这个

私有列表myURL=

@Override
public void onBindViewHolder(ViewHolder viewHolder, int position) {
  ImageView imageView = ((MyViewHolder) viewHolder).imageView;
  String currentUrl = myUrls.get(position);

  Glide.with(fragment)
    .load(currentUrl)
    .override(imageWidthPixels, imageHeightPixels)
    .into(imageView);
}

“context”包含传递给适配器的活动或片段的实例


“context”包含传递给适配器的活动或片段的实例

我通过更改ImageView属性解决了这个问题


android:width:“wrap\u content”
更改为
android:width:“match\u parent”

我通过更改ImageView属性解决了这个问题


android:width:“wrap\u content”
更改为
android:width:“match\u parent”

您找到过解决方案吗?您找到过解决方案吗?