SimpleCursorAdapter already does the convertView optimization for you.
Just avoid allocations in setViewValue().

On Wed, Apr 8, 2009 at 12:00 PM, DavidG <[email protected]> wrote:
>
> In my application, I have a ListView with a SimpleCursorAdapter, and
> using setViewBinder to format each row of data accordingly. It works,
> but I noticed while debugging that as I scroll up and down my list,
> the binder's setViewValue() function is called for each row as it is
> shown on the screen, and basically reformats the rows over and over
> again as long as I scroll up and down. So if I have 20 items in my
> list, setViewValue() is called 20 times as I scroll from top to
> bottom. If I scroll back up, its called again as each row is shown. If
> I sit there and just keep scrolling my list, a lot of garbage
> collection happens as a result.
>
> I'm looking for ways to optimize this to hopefully reduce the need to
> re-format each row as it is displayed. If it's already been formatted
> with setViewValue(), is there a way I can skip doing it again as I
> scroll back up? Am I missing something here?
>
> I came across a comment from Romain Guy on a "Fancy ListViews"
> tutorial (http://androidguys.com/?p=635) regarding the use of
> convertView which sounds like it would optimize things. Unfortunately,
> I can't find a way to apply the logic to my application using the
> SimpleCursorAdapter.
>
> Am I on the right track? Or is this "good enough" to accept the
> frequent setViewValue() calls when scrolling? I'm still leaning, but
> I'd like to at least learn the right way from the start!
>
> >
>



-- 
Romain Guy
Android framework engineer
[email protected]

Note: please don't send private questions to me, as I don't have time
to provide private support.  All such questions should be posted on
public forums, where I and others can see and answer them

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

Reply via email to