http://bbs.csdn.net/topics/390196217
java
出現此bug的緣由是在內存回收上。裏面用Bitamp的代碼爲:android
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);
在回收時,應該這樣寫:ide
@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/39698459spa