views:

86

answers:

2

Hi,

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.

+1  A: 

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

Yes, you can specify android:inputType XML attribute with the number or numberDecimal value:

<EditText 
android:text="" 
android:id="@+id/editTextNumber" 
android:layout_width="fill_parent" 
android:layout_height="wrap_content" 
android:inputType="numberDecimal">
</EditText>

Enjoy!!

PM - Paresh Mayani
have you tried it with Webview?? @Shivaansh
PM - Paresh Mayani
Hi Paresh. Thanks for response. We are facing this problem towards WebView usage only.
Shivaansh Gupta
+1  A: 

editTextField.setRawInputType(Configuration.KEYBOARD_QWERTY); This shows the normal key pad with the numeric version first, yet allows you to switch between them.

etInput.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.