Run*_*ion 5 android android-resources
一些研究和实践后,我发现,我们可以访问使用其他应用程序的资源PackageManager像
Resources resources = getApplicationContext().getPackageManager().getResourcesForApplication(appPackageName);
Run Code Online (Sandbox Code Playgroud)
但仅仅访问Resources是不够的.我们需要每个Resource组件的ID,如Drawables,layouts,Strings等等......从Resources访问它们.
我已经搜索过SO并且自己也在努力解决如何获取其他应用程序的资源ID但却没有得到适当的解决方案.我在SO中看到,有些人建议使用像
resources.getIdentifier(String name, String defType, String defPackage);
resources.getValue(String name, TypedValue outValue, boolean resolveRefs);
resources.getValue(int id, TypedValue outValue, boolean resolveRefs);
Run Code Online (Sandbox Code Playgroud)
但是没有Idea如何使用它们.
我需要访问其他应用程序的资源(Drawables,Strings,Layouts ...).
帮助我解决这个问题.任何帮助将不胜感激...
谢谢大家,对不起我的英语......
| 归档时间: |
|
| 查看次数: |
1738 次 |
| 最近记录: |