【发布时间】:2016-12-17 21:22:17
【问题描述】:
我希望将我的应用程序设置为使用 value-th\string.xml(我拥有泰语中的所有字符串值)。这就是我要做的。 -应用程序启动。检查 sharepreference 值语言(在这种情况下为英语/泰语)如果是泰语,我将运行泰语。我有这个功能,但是,我注意到在语言环境中,我没有泰语选项。
public static void updateLanguageResources(Context context, String language) {
Locale locale = new Locale(language);
Locale.setDefault(locale);
Resources resources = context.getResources();
android.content.res.Configuration configuration = resources.getConfiguration();
configuration.locale = locale;
resources.updateConfiguration(configuration, resources.getDisplayMetrics());
}
我还尝试使用以下代码通过设置进行更改。但是,这会将电话设置更改为泰语,我的意图是更改仅适用于我的应用程序。不是设备的设置。
Intent intent = new Intent(Settings.ACTION_LOCALE_SETTINGS);
startActivity(intent);
欢迎提出任何建议。提前致谢。
【问题讨论】:
-
试试这个演示:androidhive.info/2014/07/…
-
@Damini 这就是 Intent intent = new Intent(Settings.ACTION_LOCALE_SETTINGS);开始活动(意图);做。我可以将设备语言更改为泰语,但这会影响手机中的所有应用程序。我只想在我自己的应用程序中使用泰语。
-
找到了这个[链接]stackoverflow.com/questions/2264874/…让我先试试
-
hm.. 我想我遇到了同样的问题 Locale 没有泰语选项。
-
找到了答案。谢谢。