Convert Bitmap / Drawable to Drawable (int)

0

I need to convert a Bitmap or even a Drawable into a Drawable (int), since I'm using a Bootstrap for android that needs an object of this type, but since I'm downloading the image from a url and not picking it internally, I'm getting it.

Here's the snippet:

Bitmap bitIcon = BitmapFactory.decodeStream(url.openConnection().getInputStream());
Drawable drawable = new BitmapDrawable(getResources(), bitIcon);
imgPerfil.setImage();

On the third line it asks for an integer, but I only have the Drawable Object and not its id. I wanted to know how to fetch this integer.

    
asked by anonymous 17.03.2014 / 15:04

1 answer

1

To convert a Bitmap to Drawable do the following:

Drawable seuDrawable = new BitmapDrawable(getResources(),seuBitmap);

However, as you requested, you need to search for Drawable for the id then use:

Bitmap seuBitmap = (Bitmap) findViewById(R.id.seuIdDoDrawable);
Drawable seuDrawable = new BitmapDrawable(getResources(),seuBitmap);
    
17.03.2014 / 15:07