Search code examples
androiduniversal-image-loader

ImageLoader and loading images from app's resources


Is this possible to use Universal ImageLoader for drawables inside my app's resources instead of url? I mean something like this, but with drawable:

imageLoader.displayImage(url, imageView, options);

Edit:

I want to include it into adapter so it will get less laggy... Code below is not working, but at least you will know what I had in my mind.

public View getView(int position, View convertView, ViewGroup parent) {
    View v = convertView;

    if(v == null) {
        LayoutInflater inflater = LayoutInflater.from(context);
        v = inflater.inflate(R.layout.champion_list, null);

        holder.txt = (TextView)v.findViewById(R.id.txt);
        holder.img = (ImageView)v.findViewById(R.id.img);

        v.setTag(holder);
    }

    else {
        // View recycled !
        // no need to inflate
        // no need to findViews by id
        holder = (ViewHolder) v.getTag();
    }

    holder.txt.setText(web[position]);
    //holder.img.setImageResource(imageId[position]);
    String imageUri = "drawable://" + imageId[position];
    imageLoader.displayImage(imageUri, holder.img);

    return v;

}

static class ViewHolder {
    TextView txt;
    ImageView img;
}

Solution

  • is this what you want ?

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