将原有项目图片加载框架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的更多相关文章

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

    概述 在使用Glide加载图片时,如果出现"You must not call setTag() on a view Glide is targeting"的错误,八成是在使用Li ...

  2. 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之前请求的标记被清除,强制转 ...

  3. You must not call setTag() on a view Glide is targeting when use Glide

    以下代码是一个显示图片的RecyclerView 的Adapter用到的,当点击图片,跳到另一个Activity显示大图.RecyclerView 与ListView不同 然而没有setOnClick ...

  4. “You must not call setTag() on a view Glide is targeting” 解决

    报错原因大致是因为Glide加载的iamgeView调用了setTag()方法导致的错误, 因为Glide已经默认为ImageView设置的Tag. 解决办法:自定义一个Application,在里面 ...

  5. [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类中很有用的一个方法,可以用它来给空间附加一些信息 ...

  6. 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 ...

  7. 严重: Error starting static Resources java.lang.IllegalArgumentException:

    严重: Error starting static Resources java.lang.IllegalArgumentException: Document base E:\myworkspace ...

  8. 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. ...

  9. 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\ ...

随机推荐

  1. Longest Valid Parentheses 每每一看到自己的这段没通过的辛酸代码

    Longest Valid Parentheses My Submissions Question Solution  Total Accepted: 47520 Total Submissions: ...

  2. SQL语句中如何把文件以二进制数组形式存入数据库

    System.IO.FileStream fs = new FileStream("1.txt", FileMode.Open); string strConn = "D ...

  3. iOS设置UISearchBar光标的颜色

    [[UISearchBar appearance] setTintColor:[UIColor blackColor]];

  4. C++中复制构造函数

    复制构造函数 复制构造函数用于: 根据另一个同类型的对象显示或隐式初始化一个对象 复制一个对象,将它作为实参传给一个函数 从函数返回时复制一个对象 初始化顺序容器中的元素 根据元素初始化式列表初始化数 ...

  5. RHEL5.8使用yum安装X Window System

    硬件配置:4C+16GB 操作系统:Red Hat Enterprise Linux Server release 5.8 (Tikanga) 服务器中使用的是RHEL5.8操作系统,只安装了基本的功 ...

  6. HibernateTemplate和HibernateDaoSupport(spring注入问题)

    HibernateTemplate HibernateTemplate是spring提供的一个就hibernate访问持久层技术而言.支持Dao组件的一个工具.HibernateTemplate提供持 ...

  7. 12 个 Web 设计师必备的 Bootstrap 工具

    转自:http://www.oschina.net/translate/12-best-bootstrap-tools-for-web-designers Bootstrap是一个非常棒的前端网站开发 ...

  8. 更改vsts源代码绑定服务器地址方法

    第一步找到更改源代码管理 第二步首先选中第一个,滚动条拉至最后一项,点击最后一项(全选). 第三步点击绑定,vsts会自动签出所有项目,而后签入就可以更改成功了.

  9. 【Windows 10 IoT - 3】Windows 10 RTM安装及新特性(树莓派 Pi2)

    在<[Window 10 IoT - 1]Window 10系统安装(树莓派 Pi2)>中,我们介绍了Windows 10 IoT预览版的安装,正式版Windows 10 IOT(OS版本 ...

  10. AngularJS Providers 详解

    供应者(Providers) Each web application you build is composed of objects that collaborate to get stuff d ...