开发者

scroll change listener on blackberry

When I execute the following code on a simulator it throws stackoverflow error.

I think the error came for, Each newhorizontalScroll value when I scroll.

How to avoid it or how to calculate the final horizontal scroll value?

int customfiledwidth = Display.getWidth()/3;


HorizontalFieldManager horizontalScr开发者_如何转开发ollLayout = new HorizontalFieldManager(HorizontalFieldManager.HORIZONTAL_SCROLL)
horizontalScrollLayout.setScrollListener(this);

// i add number of customfield on horizontalscrolllayout.....

public void scrollChanged(Manager manager, int newHorizontalScroll,int newVerticalScroll) 
{
    {

        horizontalScrollLayout.setHorizontalScroll(newHorizontalScroll);
        int fieldIndex =horizontalScrollLayout.getFieldAtLocation(newHorizontalScroll+customfieldwidth,0);
        Field f = horizontalScrollLayout.getField(fieldIndex);
        f.setFocus();
        invalidate();
        }}
    }


You're getting into an infinite loop pretty much by calling setHorizontalScroll() on the same Field that you are listening to its scroll. I would remove this line and see if your code works.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜