Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use Universal Image Loader

I have a requirement where I need to load thumbnails and a Text in ListView which gets set by the custom Adapter. The Thumbnails should be stored in a cache memory, for that I am using the Universal Image Loader however I am pretty much confused in the implementation of it and how to use it as per my requirement in to load the images in ListView from URL. Please suggest me some ways for it with good implementation.

like image 919
Nitin Bathija Avatar asked Dec 13 '12 06:12

Nitin Bathija


People also ask

Which library do we use to display images from Internet in Kotlin?

COIL is an image loading library for Android supported by Kotlin Coroutines. COIL is fast and performs a number of optimizations including memory and disk caching, downsampling the image in memory, re-using bitmaps, automatically pausing/canceling requests, and more.


2 Answers

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

like image 156
Dipak Keshariya Avatar answered Sep 20 '22 19:09

Dipak Keshariya


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);
like image 20
user1787773 Avatar answered Sep 16 '22 19:09

user1787773