Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

like image 292
Jigar Joshi Avatar asked Feb 24 '16 07:02

Jigar Joshi


Video Answer


1 Answers

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

like image 178
Jigar Joshi Avatar answered Oct 16 '22 23:10

Jigar Joshi