Replace (or “Override”) String in Android Library Project

筅森魡賤 提交于 2019-11-28 19:12:36
R Miller

I have the same arrangement and this works for me as expected.

The library has layout/class with this reference to a string resources:

<TextView android:id="@+id/studentSinceLabel">

The library provides a default value in its strings.xml:

<string name="studentSinceLabel">Student Since</string>

The main app has this value in its strings.xml:

<string name="studentSinceLabel">Client Since</string>

When I givve a value for this resource in the main apps strings.xml, I see "Client Since" when the app runs, when I delete it from the main apps strings.xml, I see the value from the library, "Student Since".

Seems this is expected behavior based on my reading here: http://developer.android.com/tools/sdk/eclipse-adt.html

Relevant quote from link above:

In the cases where a resource ID is defined in both the application and the library, the tools ensure that the resource declared in the application gets priority and that the resource in the library project is not compiled into the application .apk. This gives your application the flexibility to either use or redefine any resource behaviors or values that are defined in any library.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!