Hello,
I am having the following problem. I am trying to add images to a ListView with a small icon representing each image. It works perfectly for a small amount of images but not when i have 200. I am trying to recycle Bitmap1 each time after it gets asigned to the ListView and it finishes correctly but after that (after finishing the assignation to the ListView without errors i get an error at the end). I am using Andrew Graham reflection library to recycle the bitmap1 because if i have many images i get an out of memory.
For i = 0 To Bitmaps.Size-1
Log("Bitmaps.Get("&i&"):"&Bitmaps.Get(i))
Bitmap1.InitializeSample(File.DirAssets, Bitmaps.Get(i),50dip,50dip)
ListView1.AddTwoLinesandBitmap(Nombres.get(i) ,Nombres2.Get(i) , Bitmap1)
Obj1.Target=Bitmap1
Obj1.RunMethod("recycle")
Next
Log("Finished loading image icons:"&i)
Bitmaps.Get(224):225youreallygome.gif
Bitmaps.Get(225):226yousangtome.gif
Finished loading image icons:226
** Activity (main) Resume **
Shutting down VM
threadid=1: thread exiting with uncaught exception (group=0x4001d800)
FATAL EXCEPTION: main
java.lang.RuntimeException: Canvas: trying to use a recycled bitmap android.graphics.Bitmap@44f26618
at android.graphics.Canvas.throwIfRecycled(Canvas.java:955)
at android.graphics.Canvas.drawBitmap(Canvas.java:1044)
at android.graphics.drawable.BitmapDrawable.draw(BitmapDrawable.java:323)
at android.view.View.draw(View.java:6725)
at android.view.ViewGroup.drawChild(ViewGroup.java:1640)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1367)
at android.view.ViewGroup.drawChild(ViewGroup.java:1638)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1367)
at android.widget.AbsListView.dispatchDraw(AbsListView.java:1365)
at android.widget.ListView.dispatchDraw(ListView.java:3046)
at android.view.View.draw(View.java:6846)
at android.widget.AbsListView.draw(AbsListView.java:2257)
at android.view.ViewGroup.drawChild(ViewGroup.java:1640)
Please help. What am i doing wrong. Is it not the correct method to recycle the bitmap? why is it failing?
Thanks a lot and best regards,
I am having the following problem. I am trying to add images to a ListView with a small icon representing each image. It works perfectly for a small amount of images but not when i have 200. I am trying to recycle Bitmap1 each time after it gets asigned to the ListView and it finishes correctly but after that (after finishing the assignation to the ListView without errors i get an error at the end). I am using Andrew Graham reflection library to recycle the bitmap1 because if i have many images i get an out of memory.
For i = 0 To Bitmaps.Size-1
Log("Bitmaps.Get("&i&"):"&Bitmaps.Get(i))
Bitmap1.InitializeSample(File.DirAssets, Bitmaps.Get(i),50dip,50dip)
ListView1.AddTwoLinesandBitmap(Nombres.get(i) ,Nombres2.Get(i) , Bitmap1)
Obj1.Target=Bitmap1
Obj1.RunMethod("recycle")
Next
Log("Finished loading image icons:"&i)
Bitmaps.Get(224):225youreallygome.gif
Bitmaps.Get(225):226yousangtome.gif
Finished loading image icons:226
** Activity (main) Resume **
Shutting down VM
threadid=1: thread exiting with uncaught exception (group=0x4001d800)
FATAL EXCEPTION: main
java.lang.RuntimeException: Canvas: trying to use a recycled bitmap android.graphics.Bitmap@44f26618
at android.graphics.Canvas.throwIfRecycled(Canvas.java:955)
at android.graphics.Canvas.drawBitmap(Canvas.java:1044)
at android.graphics.drawable.BitmapDrawable.draw(BitmapDrawable.java:323)
at android.view.View.draw(View.java:6725)
at android.view.ViewGroup.drawChild(ViewGroup.java:1640)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1367)
at android.view.ViewGroup.drawChild(ViewGroup.java:1638)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1367)
at android.widget.AbsListView.dispatchDraw(AbsListView.java:1365)
at android.widget.ListView.dispatchDraw(ListView.java:3046)
at android.view.View.draw(View.java:6846)
at android.widget.AbsListView.draw(AbsListView.java:2257)
at android.view.ViewGroup.drawChild(ViewGroup.java:1640)
Please help. What am i doing wrong. Is it not the correct method to recycle the bitmap? why is it failing?
Thanks a lot and best regards,