number Validation in Android
posted Jan 25, 2011, 2:43 AM by Thiyagaraaj M [ updated Feb 1, 2011, 7:22 AM by Thiyagaraaj Mp ]
XML Code:
<EditText id ="@+id/edittext1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:numeric="integer"
/>
{
Pattern numberPattern = Pattern.compile("0-9]*");
Matcher numberMatcher = numberPattern.matcher(numberstring);
return numberMatcher.matches();
}
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();
}