简体   繁体   English

如何打开键盘和更改输入语言

[英]How to open keyboard and change input language

How to: - open keyboard without focus on edittext, - check which languages are installed and - change input language to other language? 如何:-打开键盘而不关注于edittext,-检查安装了哪些语言,以及-将输入语言更改为其他语言?

Thanks 谢谢

It's possible. 这是可能的。 You can set the locale. 您可以设置区域设置。 However, i would not recommend that. 但是,我不建议这样做。 We've tried it at early stages, it's basically fighting the system. 我们已经在早期阶段进行了尝试,基本上是在与系统抗争。 We have same requirement for changing language, but decided to settle to the fact that UI should be same as phone UI. 我们对更改语言有相同的要求,但决定解决UI与电话UI相同的事实。 It was working via setting locale but was too buggy. 它可以通过设置区域设置来工作,但是却存在很多问题。 And you have to set it every time you enter activity ( each activity ) from my experience. 根据我的经验,每次输入活动(每个活动)时都必须进行设置。 here is a code if you still need this ( again, i don't recommend that ) 这是一个代码,如果您仍然需要此代码(再次,我不建议这样做)

Resources res = context.getResources();
// Change locale settings in the app.
DisplayMetrics dm = res.getDisplayMetrics();
android.content.res.Configuration conf = res.getConfiguration();
conf.locale = new Locale(language_code.toLowerCase());
res.updateConfiguration(conf, dm);

If you have language specific content - you can change that base on the setting. 如果您有特定于语言的内容-您可以根据设置更改该内容。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM