Skip to content

Commit

Permalink
✏️ Add the OnScrollListener example
Browse files Browse the repository at this point in the history
  • Loading branch information
ShawnLin013 committed Feb 25, 2020
1 parent ce08f44 commit 8326fd3
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,16 @@ numberPicker.setOnValueChangedListener(new NumberPicker.OnValueChangeListener()
Log.d(TAG, String.format(Locale.US, "oldVal: %d, newVal: %d", oldVal, newVal));
}
});

// OnScrollListener
numberPicker.setOnScrollListener(new NumberPicker.OnScrollListener() {
@Override
public void onScrollStateChange(NumberPicker picker, int scrollState) {
if (scrollState == SCROLL_STATE_IDLE) {
Log.d(TAG, String.format(Locale.US, "newVal: %d", picker.getValue()));
}
}
});
```

#### XML
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,16 @@ public void onValueChange(NumberPicker picker, int oldVal, int newVal) {
Log.d(TAG, String.format(Locale.US, "oldVal: %d, newVal: %d", oldVal, newVal));
}
});

// OnScrollListener
numberPicker.setOnScrollListener(new NumberPicker.OnScrollListener() {
@Override
public void onScrollStateChange(NumberPicker picker, int scrollState) {
if (scrollState == SCROLL_STATE_IDLE) {
Log.d(TAG, String.format(Locale.US, "newVal: %d", picker.getValue()));
}
}
});
}

}

0 comments on commit 8326fd3

Please sign in to comment.