Skip to content

Commit 07ddb46

Browse files
sganovAndroid (Google) Code Review
authored andcommitted
Merge "NumberPicker should adjust min and max when displayed values are set." into jb-mr1-dev
2 parents 94ffe87 + a1410e6 commit 07ddb46

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

core/java/android/widget/NumberPicker.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1361,6 +1361,14 @@ public void setDisplayedValues(String[] displayedValues) {
13611361
// Allow text entry rather than strictly numeric entry.
13621362
mInputText.setRawInputType(InputType.TYPE_CLASS_TEXT
13631363
| InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);
1364+
// Make sure the min, max, respect the size of the displayed
1365+
// values. This will take care of the current value as well.
1366+
if (getMinValue() >= displayedValues.length) {
1367+
setMinValue(0);
1368+
}
1369+
if (getMaxValue() >= displayedValues.length) {
1370+
setMaxValue(displayedValues.length - 1);
1371+
}
13641372
} else {
13651373
mInputText.setRawInputType(InputType.TYPE_CLASS_NUMBER);
13661374
}

0 commit comments

Comments
 (0)