Closed tompad2 closed 7 years ago
/* * Scroll the spinnerwheel * @param itemsToScroll items to scroll * @param time scrolling duration / public void scroll(int itemsToScroll, int time) { int distance = itemsToScroll \ getItemDimension() - mScrollingOffset; onScrollTouched(); // we have to emulate touch when scrolling spinnerwheel programmatically to light up stuff mScroller.scroll(distance, time); }
The above function will call when you calling setCurrentItem(pos) .
getItemDimension() Returns base dimension of base item — width for horizontal spinnerwheel / height for vertical.
In onCreate method the view does not get measured completely. So it return 0 always.
Use handler to set current item after few seconds like below
Handler handler = new Handler(); handler.postDelayed(new Runnable() { @Override public void run() { BpmWheel.setCurrentItem(pos); } }, 50);
Hi! Thanks for a great wheelwidget! Looking forward to see the new version coming up!
I have a wheel constructed in onCreate like this:
final AbstractWheel BpmWheel = (AbstractWheel) findViewById(R.id.bpmWheel); final NumericWheelAdapter bpmAdapter = new NumericWheelAdapter(this, 10, 300, "%02d"); bpmAdapter.setItemResource(R.layout.wheel_text_centered2); bpmAdapter.setItemTextResource(R.id.text); BpmWheel.setViewAdapter(bpmAdapter); BpmWheel.setCurrentItem(pos);
How can I change the pos outside the onCreate?? I am trying to call BpmWheel.setCurrentItem(pos) in another method but AndroidStudio mark it like error...
Sorry if this is a dumb question....I am rather new at programming.