简体   繁体   中英

show English keyboard for EditText(Android)

In my android application I used EditText to take text input from user. I want that EditText only accept selective characters, for that in xml file I mentioned following property for EditText.

android:digits="@string/customDigits"

and customDigits is mentioned in strings.xml

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

I gave multilanguage support for my android applicaton. When I choose languages like FRENCH,GERMAN,SPANISH and EditText is in focus then it shows proper English keyboard as shown :-

在此输入图像描述

But when I select JAPANESE language and EditText is in focus then it shows Japanes keyboard as shown :-

在此输入图像描述

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.

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.

Hope it can help in somehow. forceAscii

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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