I have set an Android ImageButton’s Bitmap to a jpeg from the net via a HTTPUrlConnection and want to change it when the user clicks it. I set up a View.onClickListener which gets triggered correctly but the code it fires doesnt seem to chaneg the image on the button.
I fire ImageButton1.setBackgroundResource(R.drawable.image1); however im thinking maybe the background is behind the Bitmap already set (as the name suggests). What should i be doing to set R.darwable.image1?
Current code;
View.OnClickListener handlerImgBtnCatCelebrities1 = new View.OnClickListener()
{
@Override
public void onClick(View v)
{
ImageButton1.setBackgroundResource(R.drawable.image1);
}
};
What about, setImageResource()?
Don’t get confused by the fact that this method refers to the
ImageViewclass, because anImageButtonis actually anImageViewor in other words: theImageButtonclass extends theImageViewclass.ImageButton
Rolf