A_user A_user - 1 year ago 129
Android Question

How to create Drawable from resource

I have a image


I want to pass this image to a function which accepts

(e.g. mButton.setCompoundDrawables())

So how to convert a image resource to an

Answer Source

Your Activity should have the method getResources. Do:

Drawable myIcon = getResources().getDrawable( R.drawable.icon );
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download