黑莓滚动变化监听 [英] scroll change listener on blackberry

查看:403
本文介绍了黑莓滚动变化监听的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我执行以下code在模拟器上它抛出计算器错误。

我觉得,当我滚动每个newhorizo​​ntalScroll价值附带的错误。

如何避免它,或者如何计算最终水平滚动价值?

  INT customfiledwidth = Display.getWidth()/ 3;
Horizo​​ntalFieldManager horizo​​ntalScrollLayout =新Horizo​​ntalFieldManager(Horizo​​ntalFieldManager.HORIZONTAL_SCROLL)
horizo​​ntalScrollLayout.setScrollListener(本);//我在horizo​​ntalscrolllayout添加的CustomField数.....公共无效scrollChanged(经理经理,INT newHorizo​​ntalScroll,诠释newVerticalScroll)
{
    {        horizo​​ntalScrollLayout.setHorizo​​ntalScroll(newHorizo​​ntalScroll);
        INT字段索引= horizo​​ntalScrollLayout.getFieldAtLocation(newHorizo​​ntalScroll + customfieldwidth,0);
        域F = horizo​​ntalScrollLayout.getField(字段索引);
        f.setFocus();
        无效();
        }}
    }


解决方案

您正在进入一个无限循环pretty通过调用多少 setHorizo​​ntalScroll()的同场,你是听其滚动。我会删除此行,看看你的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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆