I am using a ListView
to display some images and captions associated with those images. I am getting the images from the Internet. Is there a way to lazy load images so while the text displays, the UI is not blocked and images are displayed as they are downloaded?
The total number of images is not fixed.
I've written a tutorial that explains how to do lazy-loading of images in a listview. I go into some detail about the issues of recycling and concurrency. I also use a fixed thread pool to prevent spawning a lot of threads.
Lazy loading of images in Listview Tutorial
This is a common problem on Android that has been solved in many ways by many people. In my opinion the best solution I've seen is the relatively new library called Picasso. Here are the highlights:
Jake Wharton
of ActionBarSherlock fame.ListView
detection1. Picasso allows for hassle-free image loading in your application—often in one line of code!
Use Gradle:
Just one line of code!
2. Glide An image loading and caching library for Android focused on smooth scrolling
Use Gradle:
// For a simple view:
3. fresco is a powerful system for displaying images in Android applications.Fresco takes care of image loading and display, so you don't have to.
Getting Started with Fresco
You must try this Universal Loader is best. I am using this after done many RnD on lazy loading .
Universal Image Loader
Features
Android 2.0+ support
I can recommend a different way that works like a charm: Android Query.
You can download that JAR file from here
As an example:
It's very fast and accurate, and using this you can find many more features like animation when loading, getting a bitmap (if needed), etc.
Give Aquery a try. It has amazingly simple methods to load and cache images asynchronously.