I have an image res/drawable/test.png
(R.drawable.test).
I want to pass this image to a function which accepts Drawable
, e.g. mButton.setCompoundDrawables()
.
So how can I convert an image resource to a Drawable
?
Your Activity should have the method getResources. Do:
Drawable myIcon = getResources().getDrawable( R.drawable.icon );