Android numeric input
July 10, 2010 | In Android, Development | No CommentsTo 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.