Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 991
eros Avatar asked Sep 15 '11 03:09

eros


2 Answers

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

Drawable drawable =new BitmapDrawable(bitmap);
mSwitcher.setImageDrawable(drawable);
like image 123
deepa Avatar answered Oct 06 '22 00:10

deepa


You can wrap your Bitmap in BitmapDrawable and use ImageSwitcher.setImageDrawable.

like image 40
Darth Beleg Avatar answered Oct 05 '22 23:10

Darth Beleg