I am trying to set the foreground image on an image button. After some research, I came across this code sample:
Here's what worked for me in setting the image:src
on an ImageButton
programmatically** or through code:
1.Retrieve the image drawable.
Drawable tempImage = getResources().getDrawable(R.drawable.my_image);
2.Get the view.
ImageButton tempButton = (ImageButton)findViewById(R.id.my_image_button);
3.Set the image for the view.
tempButton.setImageDrawable(tempImage);
Hope this works for you too!