如何克服这个新错误 Glide 版本 4.9.0,
错误1:
cannot found symbol class GlideDrawable
错误2:
wrong number of type argument required 1
我不是程序员,我刚刚使用一些现成的脚本开始我的第一个项目。所以我希望我能 catch 您所有的友好回复。
我已经尝试将“GlideDrawable”更改为“Drawable”,就像每个人在此类问题中所说的那样。但是同样的错误再次发生,例如“找不到符号类 Drawable”
import com.bumptech.glide.Glide;
import com.bumptech.glide.load.resource.drawable.GlideDrawable;
import com.bumptech.glide.request.RequestListener;
import com.bumptech.glide.request.target.Target;
Glide.with(context)
.load(product.getImages().get(0).getSrc())
.listener(new RequestListener<String, GlideDrawable>() {
@Override
public boolean onException(Exception e, String model, Target<GlideDrawable> target, boolean isFirstResource) {
holder.cover_loader.setVisibility(View.GONE);
return false;
}
@Override
public boolean onResourceReady(GlideDrawable resource, String model, Target<GlideDrawable> target, boolean isFromMemoryCache, boolean isFirstResource) {
holder.cover_loader.setVisibility(View.GONE);
return false;
}
})
最佳答案
GlideDrawable 在 4.x 版本中已被弃用,因此如果您从 3.x 迁移到 4.x,只需使用 Drawable。
例如,如果您在代码中的某处使用监听器,则转向简单的此方法..
Glide.with(context)
.load(product.getImages().get(0).getSrc())
.listener(new RequestListener<Drawable>() {
@Override
public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<Drawable> target, boolean isFirstResource) {
holder.cover_loader.setVisibility(View.GONE);
return false;
}
@Override
public boolean onResourceReady(Drawable resource, Object model, Target<Drawable> target, DataSource dataSource, boolean isFirstResource) {
holder.cover_loader.setVisibility(View.GONE);
return false;
}
})
关于java - 无法运行我的调试应用程序,因为出现 Glide 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56251383/