Samuel Hornby Samuel Hornby - 1 year ago 125
Android Question

How can i use images from my drawable folder in my .java file in andriod studio?

I would like to use the images from my drawable file in my .java file. do i need to make a new file instance or something? if so, how do you do that?

Answer Source

You may create a drawable of the image file,

Drawable drawable = getResources().getDrawable(getResources()
                  .getIdentifier("image_name", "drawable", getPackageName()));

Or set if directly by,

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download