views:

59

answers:

3

Hi!

I wounder if there is some different way of validating EditText on android controlls.. Or should I use the regular java way of doing this?

A: 

Depending on what your requirements are, you can look at the android:inputType attribute. This can be quite a bit easier in some cases. For example, specifying android:inputType=number will simply disallow non-numeric symbols from being entered into the EditText box.

eldarerathis
A: 

What kind of validation are we taking about?

Numbers:

android:numeric="decimal"

Length:

android:maxLength="10"

You can also provide "hints" of what the valid data should be:

android:hint="@string/numberHint"

Also see this answer

Bryan Denny
A: 

If you really want some fancy validation use the java.util.regex class

link text

(Matcher and Pattern)

NickT