Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Numeric Soft Keyboard on Android

I am developing an android application where we are using WebView to display Web page being served from Web Server. Everything is working fine except with the problem that when i am using the soft keyboard and switched to numeric key entry and move from first field to next field, the keyboard layout automatically changed to alphanumeric.

Is there any way using which i can pull up virtual keyboard in numeric mode only when i need to enter numbers only?

Thanks and Regards.

like image 586
Shivaansh Gupta Avatar asked Jul 09 '10 20:07

Shivaansh Gupta


3 Answers

editTextField.setRawInputType(Configuration.KEYBOARD_QWERTY);

This shows the normal key pad with the numeric version first, yet allows you to switch between them.

getInput.setRawInputType(Configuration.KEYBOARD_12KEY);

This shows numeric only, with no option to enter text values.

I ran into a similar situation. I wanted numeric values only, but I have a "hint" that was text. Setting the inputType to number would not allow the hint to be displayed. This works around it fine.

like image 80
user455451 Avatar answered Nov 02 '22 18:11

user455451


Configuration.KEYBOARD_12KEY or Configuration.KEYBOARD_QWERTY is wrong way.

You have to use InputType (show doc here) on the EditText setRawInputType().

like image 28
fazermokeur Avatar answered Nov 02 '22 20:11

fazermokeur


If you are talking about HTML, you could use HTML5 features, for example:

Number: <input type="number" name="points" min="1" max="10" />

Have tested this in HTC Desire browser, and it brings up different (numeric) keyboard when you enter data into such field.

like image 32
altumano Avatar answered Nov 02 '22 19:11

altumano