Correctly validate numbers when pasted in NumberPicker.

Bug #2258525
This commit is contained in:
Romain Guy
2010-03-05 17:33:20 -08:00
parent 9277c6d972
commit aa516beb79

View File

@@ -473,10 +473,13 @@ public class NumberPicker extends LinearLayout {
private int getSelectedPos(String str) {
if (mDisplayedValues == null) {
return Integer.parseInt(str);
try {
return Integer.parseInt(str);
} catch (NumberFormatException e) {
/* Ignore as if it's not a number we don't care */
}
} else {
for (int i = 0; i < mDisplayedValues.length; i++) {
/* Don't force the user to type in jan when ja will do */
str = str.toLowerCase();
if (mDisplayedValues[i].toLowerCase().startsWith(str)) {