I just want to ask, is that possible to load drawable from arraylist inside arrays.xml using Lazy Image Loader or Universal Image Loader?

First load arraylist of drawable

....

ArrayList<Integer> sample_list = new ArrayList<Integer>();

....

Resources resources = getResources();
String packageName = getApplication().getPackageName();
final String[] extras = resources.getStringArray(R.array.sample);

    for (String extra : extras) {
       int res = resources.getIdentifier(extra, "drawable", packageName);
       if (res != 0) {
           sample_list.add(res);
    }
}

Set drawable to imageview

imageView.setImageResource(sample_list.get(position));

Last time I used like above, but I want to use Lazy Image Loader or Universal Image loader

I dont use any url to load image

So is that possible?

If possible is there any sample?

有帮助吗?

解决方案

This method is not recommending for loading the images in drawable... You should use native method

Since u r using arraylist if u r saving the image name ids u can use like

String imageUri = "drawable://" + R.drawable.image;

(here this.R.drawable.image would be ur arraylist value.

NOTE:From: https://github.com/nostra13/Android-Universal-Image-Loader they are recommending to use native method if u want to show images from drawable

imageview.setImageResources(res id);
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top