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

后端 未结 2 1590
南笙
南笙 2020-12-13 18:26

I\'ve been trying to make an android library project, and while the build process works fine, I\'ve been running into some trouble with replacing a resource in the project w

2条回答
  •  天命终不由人
    2020-12-13 19:04

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

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

    
    

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

    Student Since
    

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

    Client Since
    

    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.

提交回复
热议问题