You can check out the example I wrote at code.google.com/p/shelves. It
does lazy loading of images from the sdcard.

On Tue, Dec 8, 2009 at 11:45 PM, skyhigh <[email protected]> wrote:
> I haven't tried to do a lazy background image load like you are doing,
> but have done some code that uses a holder/wrapper to store the layout
> findViewById which is a nice optimization so that it doesn't have to
> call inflate and findViewById again when each row is displayed.  My
> understanding is that when you do this it will allocate enough views
> for each of the rows that are visible on the screen, and then as a row
> scrolls off the screen, it will reuse the already initialized view for
> a new row that is scrolling onto the screen.
>
> In looking at your code I think you may have a problem because of the
> way that the views for each row get reused when they disappear from
> sight.  The same view that was used for a row that just disappeared
> can be reused for a new row that is appearing as the list scrolls.
> Your getView routine is handling this by detecting that the
> convertView is non-null when it has already been filled in when this
> view was used by a previous row.  However you don't have any mechanism
> to detect when a view has been reused and is now displaying a
> different row and the URL has changed to a different URL while the
> background AsyncTask was retrieving the image.  By the time the
> AsyncTask finishes retrieving the image, the view that it saved the
> reference to, in order to set the image, could have been reused to
> display a different row in the list.  If you can add code to check if
> it is still the expected URL prior to setting the image I think it
> might solve your problem.  If the URL has changed then skip setting
> the lazy image on that view, and just add the image to your cache.
>
> --
> 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
>



-- 
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