Reputation: 857
I am developing an android app in which I have included a library project, I am able to use the resources of library project (ie layouts, styles etc) inside my main project. But I want to use the resources of my main project inside my library project. Is there any way to do that? I am stuck at this problem for quite a time.
Upvotes: 2
Views: 1518
Reputation: 60681
You can create dummy resources inside your library project, and anything with the same name in the main project will override it.
Example:
LibProject/res/values/strings.xml:
<string name="greeting">Hello from Library Project</string>
MainProject/res/values/strings.xml:
<string name="greeting">Hello from App Project</string>
Then, wherever you use R.string.greeting
, even in your library project, the value from the main project will be used.
From the docs:
The application itself has highest priority and its resources are always used in preference to identical resource IDs defined in libraries.
Upvotes: 7