Articles‎ > ‎Android Articles‎ > ‎

number Validation in Android

posted Jan 25, 2011, 2:43 AM by Thiyagaraaj M   [ updated Feb 1, 2011, 7:22 AM by Thiyagaraaj Mp ]

number Validation in Android XML Code and Java Code

XML Code:

<EditText id ="@+id/edittext1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:numeric="integer"
/>

Java Code:

public boolean numberValidation(String numberstring)
{
Pattern numberPattern = Pattern.compile("0-9]*");
Matcher numberMatcher = numberPattern.matcher(numberstring);
return numberMatcher.matches();
}

Comments