且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

为什么要使用的strings.xml Android中?

更新时间:2023-11-15 14:41:52

当你添加字符串的strings.xml ,您可以轻松地翻译您的整个应用程序成其他语言。

When adding your strings to strings.xml, you can easily translate your whole app into other languages.

因此​​,文件夹中的你会的strings.xml 与此内容:

So in the folder values you would have strings.xml with this content:

<string name="hello">Hello</string>

值-FR A 的strings.xml 与此内容:

<string name="hello">Bonjour</string>

这可以节省你的很多的工作,而不是该做硬codeD的方式:Android的自动选择基于用户的preferences正确的语言,而且你不必担心选择和显示这种语言。

This saves you a lot of work instead of doing this the hardcoded way: Android automatically selects the correct language based on user preferences, and you don't have to worry about selecting and displaying this language.

请仔细阅读本地化| Android开发者