如何动态加载strings.xml?我可以把文件放在服务器上吗? [英] How can I load the strings.xml dynamically? Can I put the file in a server?

查看:80
本文介绍了如何动态加载strings.xml?我可以把文件放在服务器上吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为什么我问这是因为我的APK太大了.我想把它缩小.

Why i ask this is because the size of my APK is huge. I wanna make it smaller.

strings.xml中有很多字符串.我们的产品经理强迫我们支持地球上的所有语言.

There're lots of strings in strings.xml. Our product manager force us to support all languages on the earth.

我想知道,我可以只在本地放置一些strings.xml语言,然后在服务器中放置其他语言,然后当用户启动该应用程序时,根据用户的语言从其动态下载strings.xml.

I'd like to know, can I just put some languages of strings.xml locally, put others in a server, then when user launches the app, downloads the strings.xml from it dynamically according to the language of the user.

我不太清楚android如何加载strings.xml文件的过程.有任何想法吗?

I am not quite clear about the process of how android load the strings.xml file. Any idea about it?

谢谢~~

推荐答案

我可以只在本地放置一些strings.xml语言,还是在服务器中放置其他语言,然后当用户启动该应用程序时,根据用户的语言从其中动态下载strings.xml.

can I just put some languages of strings.xml locally, put others in a server, then when user launches the app, downloads the strings.xml from it dynamically according to the language of the user.

您不能在运行时修改资源.欢迎您在运行时下载和处理XML文件,这些XML文件可能包含要显示给用户的字符串.但是,您不能使用Android资源系统提取这些字符串.您将需要编写使用这些值的自己的Java代码,包括确定给定设备要使用哪种转换(考虑到Android 7.0中提供的多语言环境支持).

You cannot modify resources at runtime. You are welcome to download and process XML files at runtime, and those XML files might contain strings that you want to display to the user. However, you cannot use the Android resource system to pull in those strings. You would need to write your own Java code that uses those values, including determining which translation to use for a given device (taking into account the multiple-locale support offered in Android 7.0).

这篇关于如何动态加载strings.xml?我可以把文件放在服务器上吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆