android - 将 Android 应用中的语言更改为不受支持的语言

标签 android locale android-resources

我想允许我的 Android 应用程序的用户更改应用程序的语言。我知道我需要编写代码来更改语言环境(例如,从英语到俄语)。但是,如果我想从英语更改为没有区域设置的语言怎么办?我可以只为这个应用程序创建一个语言环境,并拥有像“values-xx”这样的文件夹,其中“xx”将是一个新的语言环境吗?

谢谢

最佳答案

我自己做的。我使用此代码更改了语言环境:

    Resources res = context.getResources();
    Configuration configuration = res.getConfiguration();

    configuration.locale = new Locale("XX"); //"XX" is language code, even if language is unsupported
    res.updateConfiguration(configuration, res.getDisplayMetrics());

我还需要创建一个新的“values-xx”文件夹并将资源文件放在那里。

关于android - 将 Android 应用中的语言更改为不受支持的语言,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32035573/

相关文章:

android - 有没有办法以编程方式禁用 Android 设备?

locale - 人行道 : can't set the locale; make sure $LC_* and $LANG are correct

Flutter - Locale 的可空性问题

android - reCaptcha 无法在 Android Webview 上停止循环

android - 我怎样才能使布局看起来像 instagram 评论?

android - android中原始和 Assets 文件夹的存储限制

c# - 来自 Resource.Designer.cs 的模糊引用智能感知错误

android - 通过从外部获取图像名称来设置不同的图像

android - 相机 API 中是否有等效于相机 2 API 方法 camera.autoFocus() 的方法?

java - 如何在 Java 中检测适当的字符串区域设置