简体   繁体   English

为EditText(Android)显示英文键盘

[英]show English keyboard for EditText(Android)

In my android application I used EditText to take text input from user. 在我的Android应用程序中,我使用EditText从用户获取文本输入。 I want that EditText only accept selective characters, for that in xml file I mentioned following property for EditText. 我希望EditText只接受选择性字符,因为我在xml文件中提到了EditText的以下属性。

android:digits="@string/customDigits"

and customDigits is mentioned in strings.xml strings.xml中提到了customDigits

<string name="customDigits">\u0022;\u005C;&amp;&lt;&gt;&#92; abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!#$%\'()*+,-./:;=?@[]_`{};|~^"*"</string>

I gave multilanguage support for my android applicaton. 我为我的android应用程序提供了多语言支持。 When I choose languages like FRENCH,GERMAN,SPANISH and EditText is in focus then it shows proper English keyboard as shown :- 当我选择FRENCH,GERMAN,SPANISH和EditText等语言时,它会显示正确的英文键盘,如下所示: -

在此输入图像描述

But when I select JAPANESE language and EditText is in focus then it shows Japanes keyboard as shown :- 但是,当我选择JAPANESE语言并且EditText处于焦点时,它会显示Japanes键盘,如下所示: -

在此输入图像描述

But I want to show English keyboard by default. 但我想默认显示英文键盘。 Kindly provide me solution. 请给我解决方案。

You can try 你可以试试

input.setRawInputType(Configuration.KEYBOARD_QWERTY);

But from UX perspective I'd say there's nothing you should be "fixing" here. 但是从用户体验的角度来看,我会说你不应该在这里“修理”。 If user decides he wants Japanese, he gets Japanese. 如果用户决定他想要日语,他会得到日语。 You expect certain characters but it's nothing to do with user language settings nor what type of keyboard he uses. 您期望某些字符,但它与用户语言设置无关,也与他使用的键盘类型无关。 It's none of your interest really - just reject his input if it is failing and ensure that error message (or UI) clearly indicates you expect ASCII (or whatever) to be entered in that EditText. 这真的不是你的兴趣 - 如果失败就拒绝他的输入并确保错误消息(或UI)清楚地表明你希望在EditText中输入ASCII(或其他)。

It may be too late, I'm facing the same issue as you. 可能为时已晚,我面临着和你一样的问题。

I came up with solution imeOptions="flagForceAscii and the keyboard displaying Roman alphabet characters as first priority. 我想出了解决方案imeOptions="flagForceAscii和键盘显示罗马字母字符作为第一优先。

Hope it can help in somehow. 希望它能以某种方式提供帮助。 forceAscii forceAscii

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

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