http://bbs.csdn.net/topics/390196217
出现此bug的原因是在内存回收上,里面用Bitamp的代码为:
top=(ImageView)view.findViewById(R.id.top); bitmap=ImgBitmap.comeFromRes(getResources(), R.drawable. top); top.setImageBitmap(bitmap); bottom=(ImageView)view.findViewById(R.id.bottom); bitmap1=ImgBitmap.comeFromRes(getResources(), R.drawable. bottom); bottom.setImageBitmap(bitmap1);
在回收时,应该这样写:
@Override public void onDestroy() { // TODO Auto-generated method stub top.setImageBitmap(null); bottom.setImageBitmap(null); ImgBitmap.MyRecycle(bitmap); ImgBitmap.MyRecycle(bitmap1); super.onDestroy(); }
@Override public void onDestroy() { // TODO Auto-generated method stub ImgBitmap.MyRecycle(mBitmap); ImgBitmap.MyRecycle(mBitmap1); top=null; bottom=null; super.onDestroy(); }
public static void MyRecycle(Bitmap bmp){ if(!bmp.isRecycled() && null!=bmp){ bmp=null; } } }总之是必须要解除与bitmap有关的所有绑定。
转载请注明出处:http://blog.csdn.net/android_jiangjun/article/details/39698459
java.lang.RuntimeException: Canvas: trying to use a recycled bitmap android.graphics.Bitmap@412d7230
原文地址:http://blog.csdn.net/android_jiangjun/article/details/39698459