Android numeric input

July 10, 2010 | In Android, Development | No Comments

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.

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