android - ImageButton difference between setBackground and setImageResource and setImageDrawable -


what difference between android:setbackground & android:setimageresource when used imageview

i trying change icon of imagebutton onclick. when used:

flashbtn.setimageresource(r.drawable.torch_icon_grey); 

i getting button covered in grey , correct drawable doesn't show. , when trying :

flashbtn.setbackground(r.drawable.torch_icon_grey); 

i getting error:setbackground ca't applied int

bonus: how setimagedrawable difference?

you can read this. think talking in xml:

android:background -> drawable use background, color in hex notation or drawable.

android:src -> sets drawable content of imageview.

however in java can use setimagedrawable(drawable drawable) setting drawable content of imageview.


Comments