How to get image from an ImageButton?

android, imagebutton

Solution

try this

Bitmap bitmap = ((BitmapDrawable)stuff.getDrawable()).getBitmap();

Problem

I'm not sure about the code, but I tried doing this: ``` ImageButton stuff = (ImageButton) createView.findViewById(R.id.stuff); int stuff2 = stuff.getId(); champs.setImageResource(stuff2); ``` But that didn't work, the Imagebutton was shrinked for some reason, there was no image, just a gray rectangle.

Original source

Related problems