本文介绍了在 Glide-4 中找不到 GlideDrawableImageViewTarget的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
为什么在 Glide4+ 中找不到 GlideDrawableImageViewTarget
?什么是替代方案?
Why GlideDrawableImageViewTarget
is not found in Glide4+? What is the alternative?
我的代码:
import com.bumptech.glide.request.target.GlideDrawableImageViewTarget;
Glide.with(getContext())
.load(R.drawable.loader_gif_image)
.diskCacheStrategy(DiskCacheStrategy.NONE)
.into(new GlideDrawableImageViewTarget(imageView));
}
推荐答案
UPDATE
如果您使用的是glide:4.9.0
Glide.with(this)
.load("")
.apply(new RequestOptions().diskCacheStrategy(DiskCacheStrategy.NONE))
.into(new DrawableImageViewTarget(imageView));
// or use this
Glide.with(this)
.load("")
.apply(new RequestOptions().diskCacheStrategy(DiskCacheStrategy.NONE))
.into(new CustomTarget<Drawable>() {
@Override
public void onResourceReady(@NonNull Drawable resource, @Nullable Transition<? super Drawable> transition) {
imageView.setImageDrawable(resource);
}
@Override
public void onLoadCleared(@Nullable Drawable placeholder) {
}
});
试试这个
Glide.with(this)
.load(R.drawable.ic_favorite)
.apply(new RequestOptions().diskCacheStrategy(DiskCacheStrategy.NONE))
.into(new SimpleTarget<Drawable>() {
@Override
public void onResourceReady(@NonNull Drawable resource, @Nullable Transition<? super Drawable> transition) {
imageView.setImageDrawable(resource);
}
});
试试这个
你可以使用new Target()代码>
Glide.with(this)
.load(R.drawable.ic_favorite)
.apply(new RequestOptions().diskCacheStrategy(DiskCacheStrategy.NONE))
.into(new Target<Drawable>() {
@Override
public void onLoadStarted(@Nullable Drawable placeholder) {
}
@Override
public void onLoadFailed(@Nullable Drawable errorDrawable) {
}
@Override
public void onResourceReady(@NonNull Drawable resource, @Nullable Transition<? super Drawable> transition) {
imageView.setImageDrawable(resource);
}
@Override
public void onLoadCleared(@Nullable Drawable placeholder) {
}
@Override
public void getSize(@NonNull SizeReadyCallback cb) {
}
@Override
public void removeCallback(@NonNull SizeReadyCallback cb) {
}
@Override
public void setRequest(@Nullable Request request) {
}
@Nullable
@Override
public Request getRequest() {
return null;
}
@Override
public void onStart() {
}
@Override
public void onStop() {
}
@Override
public void onDestroy() {
}
});
这篇关于在 Glide-4 中找不到 GlideDrawableImageViewTarget的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!