Recently encountered an error such as title, record the workaround again. This article refers to the post:
http://bbs.csdn.net/topics/390196217
This bug occurs because of a memory recycle with the Bitamp code:
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);
This should be the case when recycling:
@Overridepublic void OnDestroy () {//TODO auto-generated method Stubtop.setimagebitmap (null); Bottom.setimagebitmap ( NULL); imgbitmap.myrecycle (bitmap); imgbitmap.myrecycle (BITMAP1); Super.ondestroy ();}
Or
@Overridepublic void OnDestroy () {//TODO auto-generated method Stubimgbitmap.myrecycle (Mbitmap); Imgbitmap.myrecycle ( MBITMAP1); Top=null;bottom=null;super.ondestroy ();}
In addition the code for the Myrecycle method is as follows:
public static void Myrecycle (Bitmap bmp) {if (!bmp.isrecycled () && null!=bmp) {bmp=null;}}}
In short, it has to beunbind all bindings related to bitmap.
Reprint Please specify source: http://blog.csdn.net/android_jiangjun/article/details/39698459
Java.lang.RuntimeException:Canvas:trying to use a recycled bitmap [email protected]