In my program I would like to use two sets of wheels like the following:
hours = (WheelView) findViewById(R.id.hour);
NumericWheelAdapter hourAdapter = new NumericWheelAdapter(this, 0, 23, "%02d");
hourAdapter.setItemResource(R.layout.wheel_text_item);
hourAdapter.setItemTextResource(R.id.text);
hours.setViewAdapter(hourAdapter);
hours.setCyclic(true);
These wheels have a scrollinglistener hours.addScrollingListener(scrolledListener);
The scrollinglistener looks like this:
// Wheel scrolled listener
OnWheelScrollListener scrolledListener = new OnWheelScrollListener() {
public void onScrollingStarted(WheelView wheel) {
}
public void onScrollingFinished(WheelView wheel) {
update();
}
};
I would like to set one wheel with the value of the other but when I instantiate two listeners and scroll the first one it goes on setting wheel one and then wheel two and then wheel one again.
Is it possible to disable a one of the two scrolledListener?
I've tried this:
hours.addScrollingListener(null);
hours.setEnabled(false);
But this gave an error and the program had to be stopped.
Thanks for your help!
PS: the wheels are from * Android Wheel Control. * https://code.google.com/p/android-wheel/
I've contacted the designer, Yuri, of the wheel that i'm using and he gave me the following solution which works:
// Wheel scrolled listener
OnWheelScrollListener scrolledListener = new OnWheelScrollListener() {
boolean syncInProgress = false;
public void onScrollingStarted(WheelView wheel) {
}
public void onScrollingFinished(WheelView wheel) {
if (syncInProgress) {
syncInProgress = false;
return;
}
syncInProgress = true;
if (wheel.getId() == R.id.wheel1) {
// do something
} else if (wheel.getId() == R.id.wheel2) {
// do something else
}
}
};
Thank you all for your help!