I’m working on an android app using java in AndroidStudio. I have an ImageView pic
and I want to set its image as a .png that I have saved in my /drawable
folder. I may try
pic.setImageDrawable(R.drawable.image_name);
However, setImageDrawable()
requires a Drawable, while R.drawable.image_name
returns an Integer (the ID of the image).
How may I resolve this?
2
Answers
You can use
setImageResource()
for this:More about it here
Use this for java
and then set this drawable to your image view