Reputation: 189
I would like to leverage Android's ability to accept voice input on an EditText control that is configured for numeric input. I would like the numeric keyboard to pop up when the control gets focus. I used the following xml:
<EditText
android:id="@+id/edittext"
android:layout_width="fill_parent"
android:layout_height="wrap_content" android:numeric="decimal"
/>
This causes the numeric and symbol keyboard to appear as expected, but there is NO voice input button. If I switch the keyboard to the alphanumeric keys, the voice input button is displayed, but it's disabled.
If I remove the android:numeric="decimal" attribute, the regular abc keyboard appears and voice is enabled, and if I speak a number like, "one eighty two point six six", it works and displays 182.66 in the edittext box.
I have searched high and low for some way to enable "decimal only" voice input. I haven't been able to find any attributes on either EditText or TextView that have to do with voice input.
Can anyone help? I would rather not use the voice recognition intent and have to do everything myself if I can avoid it (although it would be a fun learning project!)
Upvotes: 2
Views: 1663
Reputation: 46856
I don't think there is going to be any out of the box way to make it work like you want. I would guess that the quickest path is set the keypad for decimal then supply your own button for voice input. Once the server gives you back the String that it thinks it heard then just validate that it is a number and put it into the edit text if so.
Upvotes: 1