How to reference a string from another package in a library using XML in Android?
- by Garret Wilson
The Android documentation tells me that I can access a string from another package by using the "package name", whatever that means:
@[<package_name>:]<resource_type>/<resource_name>
So in my manifest I want to access a string that I've placed in a separate library project, in the com.globalmentor.android package---that's where my R class is, after all:
<activity
android:label="@com.globalmentor.android:string/app_applicationlistactivity_label"
android:name="com.globalmentor.android.app.ApplicationListActivity" >
</activity>
That doesn't even compile. But this does:
<activity
android:label="@string/app_applicationlistactivity_label"
android:name="com.globalmentor.android.app.ApplicationListActivity" >
</activity>
Why? What does the Android documentation mean which it talks about the "package_name"? Why doesn't the first example work, and why does the second example work? I don't want all my resource names merged into the same R file---I want them partitioned into packages, like I wrote them.