Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions app/src/main/java/com/wangjie/wheelview/WheelView.java
Original file line number Diff line number Diff line change
Expand Up @@ -372,14 +372,20 @@ private void onSeletedCallBack() {

public void setSeletion(int position) {
final int p = position;
final int scrollY = p * itemHeight;
selectedIndex = p + offset;
this.post(new Runnable() {

WheelView.this.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
@Override
public void run() {
WheelView.this.smoothScrollTo(0, p * itemHeight);
public void onGlobalLayout() {
post(new Runnable() {
@Override
public void run() {
WheelView.this.smoothScrollTo(0, scrollY);
}
});
}
});

}

public String getSeletedItem() {
Expand Down