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.
精彩评论