Accessing application resources from the library project

前端 未结 3 1954
误落风尘
误落风尘 2020-12-06 01:23

My application depends on a library project.

The menu.xml file is within the application project.
All the java code is within the library projec

3条回答
  •  独厮守ぢ
    2020-12-06 02:21

    Yes you can if you know the package name of your library.
    Resources.getIdentifier(...)

    You can do:

    getResources().getIdentifier("res_name", "res_type", "com.library.package");

    ex:

    R.id.settings would be:

    getResources().getIdentifier("settings", "id", "com.library.package");

提交回复
热议问题