Android: How to: set the Image of ImageSwitcher by a Bitmap? setImageBitmap doesn't exist?

eros picture eros · Sep 15, 2011 · Viewed 10.1k times · Source

i can't find setImageBitmap from ImageSwitcher. is there a way to set it by a bitmap?

UPDATES1 then i found this -> set Image from file URI

But my case is, i have to draw something in the bitmap before it set to ImageSwitcher. So, is there no way to set it via bitmap? if no way, i have to output the image file from modified bitmap then use setImageURI. But this is wasting of memory.

UPDATES2 Alternative: Is there a way to dynamically store the image file from sdcard to R.drawable or R.raw to generate resource/drawable id. Then use it to setImageResource or setImageDrawable?

Answer

deepa picture deepa · Sep 15, 2011

you can convert bitmap into drawable and assign drawable to image switcher as

Drawable drawable =new BitmapDrawable(bitmap);
mSwitcher.setImageDrawable(drawable);