Skip to content Skip to sidebar Skip to footer

Loading Images In Gridview Using Universal Image Loader

I'm using the Universal Image Loader 1.8.6 library for loading dinamically images taken from web. The ImageLoaderConfiguration configuration is the following: ImageLoaderConfigurat

Solution 1:

I have solved the problem

I was just declaring option, but I wans't using it, so I have modified the line:

imageLoader.displayImage(basePath+immagine, iv);

into:

imageLoader.displayImage(basePath+immagine, iv, options);

and I have added in the options the method:

.cacheOnDisc(true)

Solution 2:

Caching is not enabled by default in UIL, so if you want use the cache you should use

// Create default options which will be used for every //  displayImage(...) call if no options will be passed to this methodDisplayImageOptionsdefaultOptions=newDisplayImageOptions.Builder()
    ...
    .cacheInMemory()
    .cacheOnDisc()
    ...
    .build();
ImageLoaderConfigurationconfig=newImageLoaderConfiguration.Builder(getApplicationContext())
    ...
    .defaultDisplayImageOptions(defaultOptions)
    ...
    .build();
ImageLoader.getInstance().init(config); // Do it on Application start

And while loading image use:

// Then later, when you want to display image
ImageLoader.getInstance().displayImage(imageUrl, imageView); // Default options will be used

Another way is

DisplayImageOptionsoptions=newDisplayImageOptions.Builder()
    ...
    .cacheInMemory()
    .cacheOnDisc()
    ...
    .build();
ImageLoader.getInstance().displayImage(imageUrl, imageView, options); 

And you can find more information here

Post a Comment for "Loading Images In Gridview Using Universal Image Loader"