Multilingual Android app: Display English keyboard in Email & Password fields

一曲冷凌霜 提交于 2019-12-12 10:12:28

问题


We are working on a multilingual Android app, targeting both English & Arabic. An issue being faced is in the Login & Registration screens, where we want the username and password fields to be entered only in English text & thus display the English keyboard, irrespective of the device locale language

Have tried setting the inputtype="email" in edittext but, this didn't work as desired.

Can someone please point out if there are any possibilities.

Thanks & regards, Jigar J


回答1:


Finally got the solution.

Usecase : Enforcing user to enter input in ‘English’ regardless of current Locale set in App(Local) or Phone (System Locale)


Solution : We have the property of EditText control called ‘imeOptions’ which allows to restrict user to enter text of specific ‘input type’.

In order to restrict user to enter ‘english’ text we only need to use ‘flagForceAscii’ property.


Usage: Via xml :

android:imeOptions="flagForceAscii"

Via java:

editText.setImeOptions(EditorInfo.IME_FLAG_FORCE_ASCII);

Version Compatibility :

This attribute was adden in API16, aka Jellybean




回答2:


You can probably look at these two posts.

  1. how to force english keyboard in android EditText

  2. How do I change the default keyboard input language in EditText in Android

Hope this helps!



来源:https://stackoverflow.com/questions/35595440/multilingual-android-app-display-english-keyboard-in-email-password-fields

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!