scroll change listener on blackberry

血红的双手。 提交于 2019-12-13 06:06:48

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!