Search code examples
androidbitmapandroid-imageviewimageswitcher

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?


Solution

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