user7913931
user7913931

Reputation:

How to convert imageurl to drawable?

First of all i searched a lot and didn't find solution for my case, i need to convert the imageUrl to drawable, what i tried as far :

File imageFile = DiskCacheUtils.findInCache(c.profilePhoto, com.nostra13.universalimageloader.core.ImageLoader.getInstance().getDiscCache());

            String file_target = "file://" + imageFile.getPath();


            BitmapDrawable bitDraw = (BitmapDrawable) BitmapDrawable.createFromPath(file_target);
            if (profilePhotos.size() == 4) break;
            BitmapDrawable drawable = bitDraw; //getResources().getDrawable(c.profilePhoto);
            drawable.setBounds(0, 0, width, height);
            profilePhotos.add(drawable);

Also i tried to load the image into bitmap via Glide, but didn't work.

How i can achieve that ?

Thanks in advance.

Upvotes: 0

Views: 1216

Answers (1)

Vijay Chaudhary
Vijay Chaudhary

Reputation: 228

first convert URL to Bitmap and pass bitmap into these function

Drawable d= new BitmapDrawable(context.getResources(), bitmap); return d;

Upvotes: 1

Related Questions