问题
I already posted my question below link..
scroll change listener on blackberry
The error has been resolved.
But i need to move the field center position after scrolling . pls give any idea... Thanks in advance... there are number of fields add in the scroll bar... after scrolling its show like this.
But i need to move the field center position like this.
Pls give any idea..
回答1:
Looks like you just need some flag to detect whether this is a sroll event originated by user, or from the code (programmatically).
If you originate a scroll event programmatically, then set some boolean, let's call it ignoreScrollEvent
, to true. Smth like this (pseudo code):
private boolean ignoreScrollEvent = false;
public void scrollChanged(Manager manager, int newHorizontalScroll,
int newVerticalScroll) {
if (!ignoreScrollEvent) {
ignoreScrollEvent = true;
// recalculate the newHorizontalScroll so the field in the focus
// gets in the middle
horizontalScrollLayout.setHorizontalScroll(newHorizontalScroll);
int fieldIndex = horizontalScrollLayout.getFieldAtLocation(
newHorizontalScroll + customfieldwidth, 0
);
Field f = horizontalScrollLayout.getField(fieldIndex);
f.setFocus();
invalidate();
} else {
ignoreScrollEvent = false;
}
}
来源:https://stackoverflow.com/questions/6883299/scroll-change-listener-on-blackberry