Add a new "Android Resource Directory" to the project

Asked

Viewed 39 times

1

Hello, I’m just getting to work with Android Studio. Well, I have a collection of images that I will use in my app and these images are separated into 3 folders. When I create a new directory in the res folder of my project, and place the images, I’m not getting the handle of these images.

this.img_atividade.setImageResource ( getResources().getIdentifier(this.name.toLowerCase () , "atividade", getPackageName()) );

In this example, I’m looking for the image id "this.name" that is inside the directory "activity"... But it doesn’t work, but if I replace "activity" with "drawable" and the image I want to look for there in drawable, it works very well.

I’ve looked around a lot, so I need to be able to reference that in R-Class, but I have doubts in the meantime.

Thank you!

  • I don’t think you can create a folder with a different name than the default one within res. You can put these images inside the assets.

  • I did what you said and it worked. Thank you!

  • Cool, I’ll put it as an answer so I can mark it as correct.

1 answer

1


I believe you can’t put a folder with a different name than the default one within res.

What you can do is put these images inside assets, there you are free to rename the folder as you wish.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.