java.lang.Class Cast Exception: com.lidroid.xutils.bitmap.core.Async Drawable cannot be cast to andr
2016-09-28 10:51
633 查看
如果使用xutils加载图片的朋友可能有的时候用上这种圆图处理会报异常
在其中加上这个判断就OK了
if(drawable instanceof BitmapDrawable){
b = ((BitmapDrawable)drawable).getBitmap() ;
}else if(drawable instanceof AsyncDrawable){
b = Bitmap
.createBitmap(
getWidth(),
getHeight(),
drawable.getOpacity() != PixelFormat.OPAQUE ? Bitmap.Config.ARGB_8888
: Bitmap.Config.RGB_565);
Canvas canvas1 = new Canvas(b);
// canvas.setBitmap(bitmap);
drawable.setBounds(0, 0, getWidth(),
getHeight());
drawable.draw(canvas1);
}
在其中加上这个判断就OK了
if(drawable instanceof BitmapDrawable){
b = ((BitmapDrawable)drawable).getBitmap() ;
}else if(drawable instanceof AsyncDrawable){
b = Bitmap
.createBitmap(
getWidth(),
getHeight(),
drawable.getOpacity() != PixelFormat.OPAQUE ? Bitmap.Config.ARGB_8888
: Bitmap.Config.RGB_565);
Canvas canvas1 = new Canvas(b);
// canvas.setBitmap(bitmap);
drawable.setBounds(0, 0, getWidth(),
getHeight());
drawable.draw(canvas1);
}
相关文章推荐
- java.lang.ClassCastException: com.bumptech.glide.request.target.SquaringDrawable cannot be cast to a
- Gson解析报错 java.lang.ClassCastException: com.google.gson.internal.StringMap cannot be cast to XXX
- java.lang.ClassCastException: com.google.gson.internal.LinkedTreeMap cannot be cast to
- java.lang.ClassCastException: java.lang.String cannot be cast to com.qbz.entity.TblUser
- java.lang.ClassCastException:android.os.BinderProxy cannot be cast to com.
- java.lang.ClassCastException: java.lang.Object cannot be cast to com.tgb.entity.Users
- 关于apk打包,报java.lang.ClassCastException:com.google.gson.internal.LinkedTreeMap cannot be cast to 的错误
- java.lang.ClassCastException: com.google.gson.internal.LinkedTreeMap cannot be cast to
- 问题 java.lang.ClassCastException: com.google.gson.internal.LinkedTreeMap cannot be cast to
- 解决spring使用动态代理类型转换失败的问题--java.lang.ClassCastException: com.sun.proxy.$Proxy$ cannot be cast to ...
- Caused by: java.lang.ClassCastException: com.tencent.mm.sdk.modelmsg.SendMessageToWX$Resp cannot be
- java.lang.ClassCastException: com.google.gson.internal.LinkedTreeMap cannot be cast to com.
- java.lang.ClassCastException: [Ljava.lang.Object; cannot be cast to com.xdcjc.model.D_Users
- java.lang.ClassCastException: com.sun.proxy.$Proxy* cannot be cast to***问题解决方案
- Spring+hibernate中的问题解决:java.lang.ClassCastException: $Proxy6 cannot be cast to com.mqEsb.service.imp
- java.lang.ClassCastException: libcore.net.http.HttpURLConnectionImpl cannot be cast to javax.net.ssl
- java.lang.ClassCastException: com.google.gson.internal.LinkedTreeMap cannot be cast to
- Dorado7保存时报转换错误 java.lang.ClassCastException: com.bstek.dorado.data.variant.Record cannot be cast to
- 解决EJB本地调用“java.lang.ClassCastException: $Proxy96 cannot be cast to com.tgb.ejb.UserManager”异常
- Cause: java.lang.ClassCastException: com.github.pagehelper.PageHelper cannot be cast to org.apache.i