Asynchronous ImageLoading in Listview android | Techbirds

Asynchronous ImageLoading in Listview:

There are some libraries available for async Image Loading.

Some Of them are:

1.Universal Image Loading

2.AndroidQuery(AQuery)

Here I will explain Async image Loading with “Universal Image Loader”.Following are the steps:

Step1: Download universal-image-loader-1.9.2.jar  file add add this in libs folder of your project.

Step2: Create the instance of ImageLoader class as in the constructor of your adapter class:

ImageLoader imgLoader = ImageLoader.getInstance();

Step3: Intialize the image loader with default configuration using this line in the constructor of your adapter :

imageLoader.init(ImageLoaderConfiguration.createDefault(con));

Step4: Set the configuration as you want using DisplayImageOptions class object as:

options = new DisplayImageOptions.Builder()

.showImageOnLoading(R.drawable.default_image) //Image during loading

.showImageForEmptyUri(R.drawable.default_image)//if empty URI (null or empty //string) will be passed to //ImageLoader.displayImage(…) //method.

.showImageOnFail(R.drawable.default_image)//Image if Image Loading failed

.cacheInMemory(true) //Sets whether loaded image will be cached in memory

.cacheOnDisk(true)//Sets whether loaded image will be cached in disk

.considerExifParams(true)//whether ImageLoader will consider EXIF parameters of //JPEG image

.displayer(new RoundedBitmapDisplayer(5))//for rounded corners

.build();

Step5:In getView method of your adapter use the following line to display images

imageLoader.displayImage(imgUrl[position], viewHolder.ivNewsImage, options, null);

For Detailed Document ans sample code use the following link:

https://github.com/nostra13/Android-Universal-Image-Loader

Thanks,

Sulabh Jain

(Android Application Developer)

1,698 total views, 1 views today

Share this Onfacebook-9246805twitter-8143717linkedin-5273738google-7399142