I use the function below to determine the last final value when the user selects a scroll on the NumberPicker. Then getValue () will update the last value.
numberPicker.setOnScrollListener(new NumberPicker.OnScrollListener() {
@Override
public void onScrollStateChange(NumberPicker numberPicker, int scrollState) {
if (scrollState == NumberPicker.OnScrollListener.SCROLL_STATE_IDLE) {
int value = numberPicker.getValue();
}
}
});
However, then I discovered that in the case where the end of the scroll is not at a certain position of the value, but between two values (for example, between 1 and 2, but a little closer to 2), after releasing the scroll, the function trigger captures getValue as 1, but scrolling will automatically end its scrolling for centralization to 2. Therefore, the last updated NumberPicker value is then set to 2 (not 1, i.e. as it was fixed in my function above).
NumberPicker? , , NumberPicker ( )?
FYI. - setOnValueChangedListener. , , NumberPicker .
!