4

I want to load image from Drawable folder using Universal Image Loader (NOSTRA my code is below

imgLoader = ImageLoader.getInstance();
imgLoader.init(new ImageLoaderConfiguration.Builder(this).build());

Now i am loading image in wallImage (ImageView) below is my code

imgLoader.displayImage("drawable://" + result, wallImage);

my problem is, it is taking to much time to load image. Can anybody give me solution what should I have to do ?

Vigbyor
  • 2,568
  • 4
  • 21
  • 35

1 Answers1

3
Imgloader.displayImage("drawable://" + result, wallImage); 

this method is not recommending for loading the images in drawable... You should use native method as Vigbyor as suggested

imageview.setImageResources(res id); 
duggu
  • 37,851
  • 12
  • 116
  • 113
Asthme
  • 5,163
  • 6
  • 47
  • 65
  • If I use setImageResource won't it mean that I'm not using the options from universal image loader? – RED_ Oct 25 '13 at 18:57
  • @RED_ i think it wil1 take default options – Asthme Oct 26 '13 at 12:36
  • To future SO users: This week I started investigating many posts on internet about best ways to load images. I experimented a little bit and manage to get a way to load images located in drawable folders "asyncly". It is faster than `Imgloader.displayImage("drawable://" + result, wallImage);` (tested with a 2560x1080px image http://cdn.screenrant.com/wp-content/uploads/A-Stormtrooper-lost-in-the-desert.-2560x1080-Imgur.jpg and drawing it inside an image view 100*100). After doing that, I discovered `universal image loader`, which I think is great, but it has the problem you mention before. – gian1200 Feb 03 '14 at 05:39
  • I will try to make a pull merge as soon as I understand how Universal Image Loader works under the hood. Until then, you may want to see the code I did. Sorry for the mess in advance, but you only need to call this: `BitmapUtil.loadResourceAsyncWithCache(context, imageView, drawableId, reqWidth, reqHeight, false)`. The code is here: https://github.com/gian1200/Android-Util. – gian1200 Feb 03 '14 at 05:43