Tuesday, May 24, 2011

[android-developers] SimpleCursorAdaptor ListView using an TextView and ImageView with over 400+ rows Memory Issues

Is this the best way or are there others?

I extend SimpleCursorAdapter and override getView(int position, View
convertView, ViewGroup parent)

I retrieve my Cursor, inflate my ImageView and TextView, pull the data
from the Cursor and populate the TextView and ImageView
on the ImageView I store my images in the database as Blob's.

When I retrieve my Blob I pull it out as a byte[] and convert it to a
Bitmap as below:
Bitmap bmp = BitmapFactory.decodeByteArray(img, 0, img.length);

Then I set my Bitmap on my ImageView as :
iv.setImageBitmap(bmp);

Now I can scroll down fine no issues but when I start scrolling back
up the list I get major memory issues and sporadic jumping(from when
the garbage collection catches up).

Can anyone tell me what the best way to accomplish this task would
be? Is there a way to recycle the bitmaps that aren't in view and
when approaching them pull them and display again?

I've searched for months and tried various techniques but I'm at a
loss to finding the one that will allow me to accomplish this task.

Thank you in advance.

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate