How to reference a string from another package in a library using XML in Android?

Posted by Garret Wilson on Stack Overflow See other posts from Stack Overflow or by Garret Wilson
Published on 2011-11-24T21:52:04Z Indexed on 2011/11/25 1:51 UTC
Read the original article Hit count: 175

Filed under:
|
|
|
|

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.

© Stack Overflow or respective owner

Related posts about android

Related posts about Xml