Android Imagebutton change Image OnClick

This misled me a bit – it should be setImageResource instead of setBackgroundResource 🙂 !!

The following works fine :

ImageButton btn = (ImageButton)findViewById(R.id.imageButton1);       
 btn.setImageResource(R.drawable.actions_record);

while when using the setBackgroundResource the actual imagebutton’s image
stays while the background image is changed which leads to a ugly looking imageButton object

Thanks.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)