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

后端 未结 5 1210
被撕碎了的回忆
被撕碎了的回忆 2020-12-16 04:09

The Android documentation tells me that I can access a string from another package by using the \"package name\", whatever that means:

@[         


        
5条回答
  •  既然无缘
    2020-12-16 04:54

    Name your resource in your package as com.globalmentor.android.app_applicationlistactivity_lab and not just app_applicationlistactivity_lab.

    .... ...
    ....

    Then you can access it from XML as

    "@string/com.globalmentor.android.app_applicationlistactivity_lab"

    and programmatically by

    getResources().getString(R.string.com_globalmentor_android_app_applicationlistactivity_lab);

    without conflicts.

提交回复
热议问题