从服务器的Android覆盖与/strings.xml下载RES /价值/ strings.xml中的文件到SD卡 [英] Override res/values/strings.xml file with /strings.xml download to sd card from server android
问题描述
我想,以取代被嵌入到的strings.xml
文件中的 APK
,由的strings.xml
文件从服务器下载并存储到我的内部 SD卡
。是否有可能引用外部标记的TextView
。我的客户希望有过在应用程序语言的完全控制。如果我成功地从服务器下载的strings.xml
,并将其存储到SD卡上,我怎么能引用标记元素各自 TextViews
。我并不真的需要code,但只有理念和critism这个方法。
I want to replace strings.xml
file which is embedded into the apk
, by a strings.xml
file downloaded from server and stored into my internal sd card
. Is it possible to reference external tags to TextView
. My clients want to have complete control over languages in the application. If i successfully download strings.xml
from server and stored it to sd card, how can i reference the tag element to respective TextViews
. I don't really need code but only ideas and critism about this method.
推荐答案
这是不可能的。如果要实现这一点,你必须设置语言在运行时创建的控件。
This is not possible. If you want to achieve this, you will have to set the language in runtime while creating your controls.
如果你有完整的布局(而不是创建动态控件),你将不得不递归扫描你的布局,寻找按钮,textviews,提示等,认识到控制和设置从下载的文件中的文本属性。
If you have complete layouts (not creating dynamic controls), you will have to recursively scan your layouts, looking for buttons, textviews, hints etc., recognize the control and set the text property from the downloaded file.
是这样的:
把你的语言在一个HashMap:
put your language in a hashmap:
HashMap<String, String> LANG = new HashMap<String, String>();
并为每个控件的标签属性布局。然后你可以找到他们是这样的:
and set the tag property for each of your controls in your layout. Then you can find them like this:
for(int i=0;i<yourLayout.getChildsCount;i++)
{
View v = yourLayout.getChildAt(i);
if(v instanceof Button){
((Buttons)v).setText(LANG.get(v.getTag()));
}
}
这篇关于从服务器的Android覆盖与/strings.xml下载RES /价值/ strings.xml中的文件到SD卡的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!