Android Studio - 语言混乱

时间:2018-02-21 06:28:31

标签: android

我正在开发应该支持3种语言的应用程序:俄语,英语,乌兹别克语。为此,我在' res'中创建了3个文件夹。文件夹,每个都有strings.xml文件

  1. 值烯
  2. 值-UZ
  3. enter image description here

    我希望将俄语作为默认语言,将英语和乌兹别克语作为选项。

    但Android Studio正在为values-en / strings.xml显示俄罗斯联邦标志,这非常奇怪。

    当我运行应用程序时,大部分时间它都能正常运行。但是当系统语言是英语时,它开始表现得非常奇怪 - 从英语切换到俄语,然后从俄语切换到英语。

    这是Android Studio的错误还是我做错了什么?有没有解决这个问题的解决方案?

2 个答案:

答案 0 :(得分:1)

您可以将其values-en更改为values-en-rGB,它会正常工作。

答案 1 :(得分:0)

您也可以更改应用中第一次运行中的locale,例如splash screeen setLocale("ra",this),或者更改Application class中的 public void setLocale(String localeCode, AppCompatActivity appCompatActivity) { new PrefManager().setLanguageForDevice(appCompatActivity, localeCode); Locale locale = new Locale(localeCode); Locale.setDefault(locale); Configuration config = new Configuration(); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { config.setLocales(new LocaleList(locale)); } else { config.locale = locale; } }

例如

PM> Scaffold-DbContext "Data Source=.\sqlexpress;Initial Catalog=Blogging;Integrated Security=True" Microsoft.EntityFrameworkCore.SqlServer -OutputDir Models
The Entity Framework Core Package Manager Console Tools don't support PowerShell version 2.0. Upgrade to PowerShell version 3.0 or higher, restart Visual Studio, and try again.
相关问题