show English keyboard for EditText(Android) - 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;&<>\ 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

Related

how we can specify input language for specific EditText(not for whole app) any help will be appreciated

how we can specify input language for specific EditText(not for the whole app) any help will be appreciated ..for example, for EditText1, I want to open the English keyboard and for EditText2 want to open some other language any help...
You can't change the user's keyboard. Only system apps can do that.
One possible workaround is to create your own custom keyboard views and switch programmatically.
For this, you have to create separate layouts and classes(extends KeyboardView) for each language keyboard
As far as I know you can't change the user's keyboard, it has to be changed by the user itself.
If you want to control if the user is introducing specific characters (f.e. chinese characters in an EditText), I would use a TextWatcher and apply a Regex pattern to evaluate the introduced String.

prefered input type EditText [duplicate]

This question already has answers here:
EditText with number keypad by default, but allowing alphabetic characters
(19 answers)
Closed 9 years ago.
This has been asked elsewhere online to no avail. Is there any way in Android to display the numeric soft keyboard when focusing on an EditText, but still allow any text to be entered?
I'd like to let the user enter quantities (e.g. "1 kg", "2 L"), so just setting inputType="number" won't work.
Add the following line of code, and it will do the trick :)
editText.setRawInputType(Configuration.KEYBOARD_QWERTY);
This will show the the numeric keypad first, but also allows you to enter free text.
More information here.
This may be device dependant but have you tried:
android:inputType="phone"
All Input Types Link
in the EditText's xml , this gives you the number pad keyboard but then you can still switch to letter's if you want. (Atleast on my Nexus One).
Note that: setRawInputType(InputType.TYPE_CLASS_NUMBER);
has the desired effect on some devices but not others...
On htc it works fine however on galaxy tab II you only get the numeric keyboard and no way to switch back to alpha.
write the code in XML,
android:numeric="integer"
android:inputType="phone"
android:digits="1234567890"
It looks like the underlying question you're dealing with is: how can I allow the user to enter quantities?
One appropriate answer is: with a numeric input, paired with some form of category select for the unit. e.g. radio, dropdown, or spinner. This is probably easier to use and also saves you the headache of having to validate your input every time.
You could also just have iron cojones and write a custom soft keyboard.
I tried many different combinations before I figured this out, but this appears to work correctly:
setRawInputType(InputType.TYPE_CLASS_NUMBER);
The key lies in the description for setRawInputType(int):
Directly change the content type integer of the text view, without
modifying any other state.

Android - Set EditText keyboard input type to symbols and numbers ("?123")

I have an editText and I want to make the number and symbols pad (the "?123") as the default input type since the user will mostly input numbers, slashes, and the percent sign.
I've look around the questions here, but those mostly show the number pad instead. I've tried the solution to this problem editText.setRawInputType(Configuration.KEYBOARD_QWERTY); but it shows the number pad on android 4.4.4.
Now I'm stuck because the input types in the xml do not seem to show the ?123 pad. I was thinking of doing it programatically instead but that seems to be a dead end as well.
Any ideas anyone?
There is no way to do that. All you can do is give it the input type. The keyboard itself will decide what to display based on the EditorInfo (which holds the input type and a few other pieces of information) and it will differ for each keyboard- remember that not all phones will use the default keyboard, and some OEMs (Samsung) have their own they replace the default with). Your only real option is to send a numeric inputType, and hope it displays what you want.
Try InputType instead of Configuration. Check this out.

How do I default to numeric keyboard on EditText without forcing numeric input? [duplicate]

This question already has answers here:
EditText with number keypad by default, but allowing alphabetic characters
(19 answers)
Closed 9 years ago.
This has been asked elsewhere online to no avail. Is there any way in Android to display the numeric soft keyboard when focusing on an EditText, but still allow any text to be entered?
I'd like to let the user enter quantities (e.g. "1 kg", "2 L"), so just setting inputType="number" won't work.
Add the following line of code, and it will do the trick :)
editText.setRawInputType(Configuration.KEYBOARD_QWERTY);
This will show the the numeric keypad first, but also allows you to enter free text.
More information here.
This may be device dependant but have you tried:
android:inputType="phone"
All Input Types Link
in the EditText's xml , this gives you the number pad keyboard but then you can still switch to letter's if you want. (Atleast on my Nexus One).
Note that: setRawInputType(InputType.TYPE_CLASS_NUMBER);
has the desired effect on some devices but not others...
On htc it works fine however on galaxy tab II you only get the numeric keyboard and no way to switch back to alpha.
write the code in XML,
android:numeric="integer"
android:inputType="phone"
android:digits="1234567890"
It looks like the underlying question you're dealing with is: how can I allow the user to enter quantities?
One appropriate answer is: with a numeric input, paired with some form of category select for the unit. e.g. radio, dropdown, or spinner. This is probably easier to use and also saves you the headache of having to validate your input every time.
You could also just have iron cojones and write a custom soft keyboard.
I tried many different combinations before I figured this out, but this appears to work correctly:
setRawInputType(InputType.TYPE_CLASS_NUMBER);
The key lies in the description for setRawInputType(int):
Directly change the content type integer of the text view, without
modifying any other state.

Android keyboard layout language

Writing a dictionary application for android.
Want to set translation direction in accord with current input language (to be more precise, language of letters displayed on soft keyboard). For example, we got language pair English-French. What I want is, when user inputs English letters (English keyboard layout displayed) translation direction is straight, and when keyboard layout changes to French, translation direction also changes to inverted.
So, question is: is there any event in an android Input Method Framework, which allows to track this layout changing. If there is not, maybe there is some standard tricks to do what I need?
Thanks in advance,
Alex
As far as I investigated there was no way to do that. So I made a custom keyboard to send a custom event (InputType) to my dictionary application.

Categories

Resources