如何在Android上的运行时生成XML资源? [英] How do I generate XML resources at runtime on Android?
本文介绍了如何在Android上的运行时生成XML资源?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的资源文件夹中有不同的strings.xml文件(values,values_fr,values_de ...),我想在运行时加载其他翻译.是否可以将新字符串添加到那些文件中,即使它已经被编译了?还是有解决方法?
I have different strings.xml files in my resources folders (values, values_fr, values_de...), and I would like to load additional translations during runtime. Is it possible to add the new strings to those files even if it has already been compiled? Or is there a workaround?
推荐答案
简单的答案是您做不到.您不能将硬编码的内容修改为APK资源.
The simple answer is that you can't. You can't modify hard-coded stuff into APK resources.
但是有一些选择.例如,您可以:
But there are some options. For instance you can:
- 比方说,读取资源,对其进行修改,然后将其保存到另一个外部文件夹(例如SD卡)
- 在这些文件上创建
AssetManager
) - 然后创建
Resources
用作存储在APK中的普通Android资源
这篇关于如何在Android上的运行时生成XML资源?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文