且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

更换(或QUOT;越权QUOT;)字符串中的Andr​​oid库项目

更新时间:2022-12-08 22:19:56

我有同样的安排,这对我的作品如预期。

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">

该库提供了在其strings.xml中的默认值:

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

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

主要应用在它的strings.xml这个值:

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

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

当我givve在主应用程序的strings.xml此资源的值,我看客户端自时,应用程序运行时,当我从主应用程序的strings.xml删除它,我看从图书馆的价值, 学生从

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".

似乎这种预期基于我在这里的阅读行为: http://developer.android.com/tools/sdk/eclipse-adt.html

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

从上面的链接的相关报价:

Relevant quote from link above:

在其中资源ID在应用程序和库定义的情况下,该工具可确保在应用程序中声明的资源获得优先权,并在库项目的资源没有编译到应用程序.apk文件。这使您的应用程序的灵活性,或者使用或者重新定义在任何库中定义的任何资源行为或值。

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.