14

I want to know how can i use nostra13 / Android-Universal-Image-Loader for displaying Images locally i.e from drawable folder along with the Memorycache. I want to use it with ViewPager. any help will be greatly appreciated.

Manoj
  • 2,739
  • 4
  • 28
  • 47

2 Answers2

35

To load images from assets and drawables you should take ExtendedImageDownloader from example project (this class is not a part of library yet) and also set it to configuration.

UPD: Loading local resources (from drawable, assets, content provider) works out of the box since UIL v1.8.0.

See README:

String imageUri = "assets://image.png"; // from assets
String imageUri = "drawable://" + R.drawable.image; // from drawables (only images, non-9patch)

NOTE: Use drawable:// only if you really need it! Always consider the native way to load drawables — ImageView.setImageResource(...) instead of using of ImageLoader.

Cfr
  • 5,013
  • 1
  • 32
  • 49
nostra13
  • 12,386
  • 3
  • 31
  • 43
  • where is ExtendedImageDownlaoder? I am using 1.8.4 with sources.jar – moDev Apr 16 '13 at 15:28
  • 2
    Removed. Loading from resources works out of the box since 1.8.0. – nostra13 Apr 16 '13 at 15:59
  • can you please answer to this [question](http://stackoverflow.com/questions/16041676/unable-to-display-images-into-gridview-using-universal-image-loader)?? – moDev Apr 16 '13 at 16:05
  • Please check this questions: http://stackoverflow.com/questions/18034576/images-not-loading-from-assets-folder-using-universal-image-loader – marienke Aug 03 '13 at 15:51
  • @NOSTRA can use gif image for default image on univeral image loader ..I try with Glide.with(context).load(R.drawable.load1).asGif().diskCacheStrategy(DiskCacheStrategy.SOURCE).crossFade().into(imgaeview); if not support how we can do it. please help us sir. – ShweLiam Jul 29 '16 at 11:10
  • No GIF support. Won't be. – nostra13 Aug 15 '16 at 13:15
1

Whenever More than one image load from resource dynamically (@runtime) than prefer these one:

String imgUri = "drawable://" + getResources().getIdentifier(imgName, "drawable", getActivity().getPackageName());

Here, imgName = Name of image in resource

Dhruv Raval
  • 4,776
  • 2
  • 28
  • 34