黑莓滚动变化监听 [英] scroll change listener on blackberry
本文介绍了黑莓滚动变化监听的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当我执行以下code在模拟器上它抛出计算器错误。
我觉得,当我滚动每个newhorizontalScroll价值附带的错误。
如何避免它,或者如何计算最终水平滚动价值?
INT customfiledwidth = Display.getWidth()/ 3;
HorizontalFieldManager horizontalScrollLayout =新HorizontalFieldManager(HorizontalFieldManager.HORIZONTAL_SCROLL)
horizontalScrollLayout.setScrollListener(本);//我在horizontalscrolllayout添加的CustomField数.....公共无效scrollChanged(经理经理,INT newHorizontalScroll,诠释newVerticalScroll)
{
{ horizontalScrollLayout.setHorizontalScroll(newHorizontalScroll);
INT字段索引= horizontalScrollLayout.getFieldAtLocation(newHorizontalScroll + customfieldwidth,0);
域F = horizontalScrollLayout.getField(字段索引);
f.setFocus();
无效();
}}
}
解决方案
您正在进入一个无限循环pretty通过调用多少 setHorizontalScroll()
的同场,你是听其滚动。我会删除此行,看看你的code ++工程。
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 horizontalScrollLayout = 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.
这篇关于黑莓滚动变化监听的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文