You must not call setTag() on a view Glide is targeting

参考

Glide加载图片报错You must not call setTag() on a view Glide is targeting
You must not call setTag() on a view Glide is targeting的解决方案

起因

今天将项目中的Picasso换成Glide结果在一个RecyclerView的Adapter中出现了这个错误。

原因

原因就是View使用setTag后导致Glide之前请求的标记被清除,强制转换过程中不能将你给定的类型判断为Request类型所致。
Glide为了防止加载图片错乱已经给图片打上标记了。

@Override
public Request getRequest() {
Object tag = getTag();
Request request = null;
if (tag != null) {
if (tag instanceof Request) {
request = (Request) tag;
  } else {
throw new IllegalArgumentException("You must not call setTag() on a view Glide is targeting");
  }
 }
  return request;
 }

解决方法

最直接的方法就是将删掉前面设置的setTag(),我就是这样解决的。
更多方案参考You must not call setTag() on a view Glide is targeting的解决方案

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容