java.lang.IllegalArgumentException: You must not call setTag() on a view Glide is targeting
将原有项目图片加载框架picasso改为glide,关于picasso和glide文档就自行查阅相关资料
显示 图片 例子
Glide.with(mContext).load(imageUrl).placeholder(defaultDrawable)
.error(defaultDrawable).dontAnimate().into(view) 显示正常
因为项目中头像是圆形利用glide实用圆头像代码如下
Glide.with(mContext)
.load(imageUrl)
.dontAnimate()
//.transform(new GlideRoundTransform(mContext,2))//方形圆解
.transform(new GlideCircleTransform2(mContext))//圆形
.into(view);
GlideCircleTransform2代码
public class GlideCircleTransform2 extends BitmapTransformation {
public GlideCircleTransform2(Context context) {
super(context);
}
@Override protected Bitmap transform(BitmapPool pool, Bitmap toTransform, int outWidth, int outHeight) {
return circleCrop(pool, toTransform);
}
private static Bitmap circleCrop(BitmapPool pool, Bitmap source) {
if (source == null) return null;
int size = Math.min(source.getWidth(), source.getHeight());
int x = (source.getWidth() - size) / 2;
int y = (source.getHeight() - size) / 2;
// TODO this could be acquired from the pool too
Bitmap squared = Bitmap.createBitmap(source, x, y, size, size);
Bitmap result = pool.get(size, size, Bitmap.Config.ARGB_8888);
if (result == null) {
result = Bitmap.createBitmap(size, size, Bitmap.Config.ARGB_8888);
}
Canvas canvas = new Canvas(result);
Paint paint = new Paint();
paint.setShader(new BitmapShader(squared, BitmapShader.TileMode.CLAMP, BitmapShader.TileMode.CLAMP));
paint.setAntiAlias(true);
float r = size / 2f;
canvas.drawCircle(r, r, r, paint);
return result;
}
@Override public String getId() {
return getClass().getName();
}
}
运行项目 提示我 java.lang.IllegalArgumentException: You must not call setTag() on a view Glide is targeting
直接开始google大法
搜索结果 http://stackoverflow.com/questions/34833627/error-you-must-not-call-settag-on-a-view-glide-is-targeting-when-use-glide/35096552#35096552
然后我将我的adapter时面全部涉及tag的全部去掉只留convertView的tag 然后在给convertView的tag加入key 区别与其它tag
if (convertView == null) {
convertView = mInflater.inflate(R.layout.broadcast_fragment_item,parent,false);
holder = new ViewHolder(convertView);
convertView.setTag(R.id.glide_tag,holder);
}else{
holder = (ViewHolder)convertView.getTag(R.id.glide_tag);
}
R.id.glide_tag是我在ids.xml定义了一个ID
java.lang.IllegalArgumentException: You must not call setTag() on a view Glide is targeting的更多相关文章
- You must not call setTag() on a view Glide is targeting
概述 在使用Glide加载图片时,如果出现"You must not call setTag() on a view Glide is targeting"的错误,八成是在使用Li ...
- Glide加载图片报错You must not call setTag() on a view Glide is targeting
报错信息为:You must not call setTag() on a view Glide is targeting 原因就是View使用setTag后导致Glide之前请求的标记被清除,强制转 ...
- You must not call setTag() on a view Glide is targeting when use Glide
以下代码是一个显示图片的RecyclerView 的Adapter用到的,当点击图片,跳到另一个Activity显示大图.RecyclerView 与ListView不同 然而没有setOnClick ...
- “You must not call setTag() on a view Glide is targeting” 解决
报错原因大致是因为Glide加载的iamgeView调用了setTag()方法导致的错误, 因为Glide已经默认为ImageView设置的Tag. 解决办法:自定义一个Application,在里面 ...
- [Android] View.setTag(key,Object) (java.lang.IllegalArgumentException: The key must be an application-specific resource id.)
转自: http://blog.csdn.net/brokge/article/details/8536906 setTag是android的view类中很有用的一个方法,可以用它来给空间附加一些信息 ...
- hadoop程序问题:java.lang.IllegalArgumentException: Wrong FS: hdfs:/ expected file:///
Java代码如下: FileSystem fs = FileSystem.get(conf); in = fs.open(new Path("hdfs://192.168.130.54:19 ...
- 严重: Error starting static Resources java.lang.IllegalArgumentException:
严重: Error starting static Resources java.lang.IllegalArgumentException: Document base E:\myworkspace ...
- Eclipse启动Tomcat时发生java.lang.IllegalArgumentException: <session-config> element is limited to 1 occurrence
在学习struts 2时,为了方便,直接从下载的struts的apps目录下的struts2-blank.war压缩包下的WEB-INF\复制的web.xml,当我启动Tomcat时,发生 java. ...
- tomcat报错java.lang.IllegalArgumentException: Document base XXXXX does not exist or is not a readable directory
启动tomcat的时候报如下错误: java.lang.IllegalArgumentException: Document base F:\java\tools\tomcat\me-webapps\ ...
随机推荐
- 使用multipart请求处理文件上传
在开发Web应用程序时比较常见的功能之一,就是允许用户利用multipart请求将本地文件上传到服务器,而这正是Grails的坚固基石——Spring MVC其中的一个优势.Spring通过对Serv ...
- com.alibaba.fastjson.JSONObject学习
JSONObject json = new JSONObject(); //设置json属性,可以是对象,数值 json.put("key",value); //获取json的普通 ...
- Json&Razor&控制器
JsonJson 属于JavaScript所以要书写在<script></script>中1.语法规则: 1.1:键值对 1.2:逗号分隔 1.3:花括号保存对象 1.4:方括 ...
- Xcode配置.pch文件
--到Xcode7都可以这么解决.亲测. 发现一个好东西.就是这个.pch文件.我的理解是他里面存放了我们在各个controller里面需要的头文件,那这样一来,就免去了在不同的ViewControl ...
- 那些年我们学过的PHP黑魔法
那些年我们学过的PHP黑魔法 提交 我的评论 加载中 已评论 那些年我们学过的PHP黑魔法 2015-04-10 Sco4x0 红客联盟 红客联盟 红客联盟 微信号 cnhonker_huc 功能介绍 ...
- Hadoop-1.2.1 安装步骤小结(ubuntu)
1.安装ubuntu系统 如果不使用云服务器,可以使用虚拟机WmWare安装,具体安装步骤这里就不讲了,ubuntu系统下载地址:http://www.ubuntu.com/download/desk ...
- ReactiveCocoa 5.0 初窥:可能是最痛的一次升级
RAC 5.0 相比于 4.0 有了巨大的变化,不仅是受 swift 3.0 大升级的影响,RAC 对自身项目结构的也进行了大幅度的调整.这个调整就是将 RAC 拆分为四个库:ReactiveCoco ...
- [Xamarin] 用Service 來製作一個Notification的時鐘 (转帖)
這篇利用來製作一個會出現在Notification的時鐘,來敘述一下 Service,在你製作的App被關閉時,可以透過Service繼續運行你想處理的部分,當然Service 也有其生命周期 接下來 ...
- 作业七:团队项目——Alpha版本冲刺阶段-01
昨天进展:准备开发环境,安装软件. 今天安排:软件框架设计. 小组一共三人,陈芝航因家里有事,与我们进行了QQ视屏会议.
- 只有好的棋手才会走运-《打造Facebook》读后感
王淮的<打造Facebook>一书不厚,花半天时间轻松读完.书中没有大段的说教,只有近乎流水的陈述.正如作者所说,打造Facebook这本书由巴克伯格来写再合适不过.可惜他至少在近几年内没 ...