Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/185.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
当手机语言从设置更改时更改android应用程序语言_Android_Android Studio_Localization - Fatal编程技术网

当手机语言从设置更改时更改android应用程序语言

当手机语言从设置更改时更改android应用程序语言,android,android-studio,localization,Android,Android Studio,Localization,当“设置”中的语言更改时,我想更改我的应用程序字符串语言 比如,现在是英语。 当我从设置中输入印地语时,我的android应用程序中的文本也应该是印地语 如何做到这一点?你应该在这个网站上: 您必须在res文件夹中创建用于本地化的values文件夹,并且必须在values文件夹中创建string.xml。例如: 土耳其的价值观 法语的值fr值hi/strings.xml स्वागतम ईमेल पता पासवर्ड लॉगिन खाता नहीं है? साइन अप करें 使

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

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

如何做到这一点?

你应该在这个网站上:

您必须在res文件夹中创建用于本地化的values文件夹,并且必须在values文件夹中创建string.xml。例如:

土耳其的价值观

法语的值fr

值hi/strings.xml

स्वागतम
ईमेल पता
पासवर्ड
लॉगिन
खाता नहीं है? साइन अप करें
使用

获取设备的设备语言。(例如en)

然后在你的应用程序中切换你的“字符串”值。(Values/string.xml)

参考:

引述:

Locale.getDefault().getLanguage()       ---> en      
Locale.getDefault().getISO3Language()   ---> eng 
Locale.getDefault().getCountry()        ---> US 
Locale.getDefault().getISO3Country()    ---> USA 
Locale.getDefault().getDisplayCountry() ---> United States 
Locale.getDefault().getDisplayName()    ---> English (United States) 
Locale.getDefault().toString()          ---> en_US
  • 创建
    值xx
    ,其中“xx”是任何语言代码,如“en”、“fr”、“sp”、“ar”。。。。等等

  • 在同一文件夹中创建名为
    string.xml
    的xml

  • 在该xml中创建字符串

    用您作为语言代码的语言编写
    
    Locale.getDefault().getLanguage();
    
    Locale.getDefault().getLanguage()       ---> en      
    Locale.getDefault().getISO3Language()   ---> eng 
    Locale.getDefault().getCountry()        ---> US 
    Locale.getDefault().getISO3Country()    ---> USA 
    Locale.getDefault().getDisplayCountry() ---> United States 
    Locale.getDefault().getDisplayName()    ---> English (United States) 
    Locale.getDefault().toString()          ---> en_US