Reputation: 2485
I've a project structure like that:
The folder "coffee_types" is an Android resource folder with type drawable created in the following way:
Previously, when I was using only main drawables folder, I was using this function to get the Drawable object:
private Drawable getDrawableByName(String name) {
return getResources().getDrawable(getResources().getIdentifier(name, "drawable", getPackageName()));
}
I was trying to change it to make it work with the "coffee_types" folder with no success.
Any help appreciated.
Upvotes: 0
Views: 531
Reputation: 35
It's not possible to access drawables from another directory.
But you could name the pictures like: "coffee_image_1", "coffee_image_2" etc. (like you did) and put them in the drawables folder.
It will be easier to find them this way.
Upvotes: 0
Reputation: 1006564
The folder "coffee_types" is an Android resource folder with type drawable
No, it is not. You cannot invent your own resource types.
Upvotes: 3