How to use Universal Image Loader

I will suggest you using AQuery - (Android-Query) - a super simple UI manipulation framework for Android.

AQuery comes as a library, which you need to include in your build path.

In AQuery, you can download, display (with effects) and cache the image (both in memory and disk) with following lines:

AQuery aq = new AQuery(yourActivity.this);
boolean memCache = true;
boolean fileCache = true;
aq.id(R.id.image1).image("http://www.example.com/image.jpg", memCache, fileCache);

AQuery will handle all the data downloading processes, and will display images on your ImageView you've given. Once you load the image, it will be cached in the memory (or disk) according to the boolean parameters memCache and fileCache. The next time, it will load the image from the memory cache or file cache.

For more information and examples, you should visit the AQuery Project at http://code.google.com/p/android-query/

More code on Image Loading - http://code.google.com/p/android-query/wiki/ImageLoading


In your adapter's oncreate() define

 ImageLoader imageLoader=new  ImageLoader(activity.getApplicationContext());

and use it in the getView() method:

imageLoader.DisplayImage(//your image url, //your imageView);

Write below code line into your adapter's getView() method, here imageUrls[position] is array of Image Urls and holder.image is imageview.

imageLoader.displayImage(imageUrls[position], holder.image, null);

And write below code line into your adapter constructor.

ImageLoader imageLoader=new  ImageLoader(activity.getApplicationContext());

it will solve your problem, And if you have any query regarding that then tell me.

And see below link for complete source code of Universal Image Loader Example.

Android - Universal Image Loader