Samuel Hornby Samuel Hornby - 5 months ago 60
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?


You may create a drawable of the image file,

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

Or set if directly by,