Android numeric input

July 10, 2010 | In Android, Development |

To restrict the input for an EditText to a numeric value, you can add the following to the layout file:

<EditText
...
android:singleLine="true"
android:inputType="numberDecimal"
...
>

Then use, for example, Double.parseDouble(…) to retrieve the value in code.

Incidentally, the documentation recommends avoiding floats and using double instead.

No Comments yet

TrackBack URI

Sorry, the comment form is closed at this time.

Login | XFN| WP
Powered by WordPress with cmb-web Theme design by Christian Bridge-Harrington.
Blog feed. Valid XHTML and CSS. ^Top^