从“设置”更改电话语言时更改 android 应用程序语言

pra*_*tix 2 android localization android-studio

当设置中的语言发生更改时,我想更改我的应用程序字符串语言。

比如,现在是英文。当我从设置切换到印地语时,我的 android 应用程序中的文本也应该是印地语。

怎么做?

Nar*_*had 5

  1. 创建values-xx其中“xx”是任何语言代码,如“en”、“fr”、“sp”、“ar”……等等

  2. string.xml在同一个文件夹中创建一个名称为 的 xml 。

  3. 在该 xml 中创建字符串

    <string name="welcome">write in the language which you put as the language code</string