更改 Android 键盘语言
如何更改 Android 键盘语言?
我设置了下面的代码来设置语言。 我从“设置”中设置了不同的语言并尝试设置英语。
Locale.setDefault(Locale.ENGLISH);
Configuration config = getResources().getConfiguration();
config.locale = Locale.ENGLISH;
getBaseContext().getResources().updateConfiguration(config, null);
How to change Android Keyboard language?
I have set below code to set language.
I set different language from Settings and trying to set English language.
Locale.setDefault(Locale.ENGLISH);
Configuration config = getResources().getConfiguration();
config.locale = Locale.ENGLISH;
getBaseContext().getResources().updateConfiguration(config, null);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
(API 24+):如果您使用的是
TextView
/EditText
,那么您可以调用 TextView#setImeHintLocales(LocaleList)注意: 这适用于很少的键盘(在在撰写本文时,GBoard 可以工作,而 SwiftKey 则不能)。
注意:如果您希望新的“提示”立即生效,您需要调用
InputMethodManager#restartInput(View)
。(API 24+): If you are using a
TextView
/EditText
, then you can call TextView#setImeHintLocales(LocaleList)Note: This works on very few keyboards (at the time of writing, GBoard works and SwiftKey doesn't).
Note: If you want new "hint" to take effect immediately you need to call
InputMethodManager#restartInput(View)
.更改
区域设置
只会将资源
(例如字符串、图像等)更改为为应用中特定区域设置
定义的资源。要更改键盘
支持的语言,您必须确保设备上安装了正确的输入法
(因为输入法本身也是一个应用程序,所以它会更改为相应的语言)。
例如,
Nexus S
上只有英文键盘,如果我需要支持其他语言的键盘,我需要找到输入法
支持该语言并安装它。为了确保用户有一个,您可以发出一些警报来吸引用户的注意力,或者通过
ACTION_XXX_SETTINGS
Intent 将他们带到键盘设置活动。Changing
locale
only changes theresources
(e.g., strings, images, etc) to those defined for a specificlocale
in an app. To change the language supported by thekeyboard
, you have to make sure a properinput method
is installed on the device(because the input method itself is also an app, it will change to a corresponding language).
For example, there is only English keyboard on
Nexus S
, if I need a keyboard that supports other language, I need to find ainput method
that supports that language, and install it.To make sure the user have one, you can make some alert to take the users' attention, or bring them to the keyboard settings activity by
ACTION_XXX_SETTINGS
intent.