Jonas452
Jonas452

Reputation: 420

ListView with Image Adapter Locking the UI Thread

I have a listview that load images with a adapter. Every time that I scroll the screen, the listview calls the getView to refresh the listview, then the getView loads a image, doing that in my ui thread, locking my screen for a moment.

What I did was to load the images in a AsyncTask class. But the problem is that it take a little bit, and when you scroll you see the wrong image, after a while it louds the right image. I didn't want to have that problem, showing the wrong image for a moment.

I search and saw that there is no way to stop that listview automatic refresh.

What should I do to resolve that problem? Any tutorial would be helpful.

Upvotes: 0

Views: 111

Answers (1)

CommonsWare
CommonsWare

Reputation: 1006859

What should I do to resolve that problem?

Set the ImageView to show a placeholder image in getView(), while you fork the task to load the real image. Or, as others have suggested, use any number of libraries for managing all of that for you (and I echo the Picasso recommendation).

Upvotes: 1

Related Questions