我正在研究黑莓曲线 8300
我在主屏幕中添加了一些组件,现在我想在轨迹球向上或向下移动时垂直移动焦点,并在轨迹轮向左或向右移动时水平移动焦点。
==================================================== =================================
--Title area that contains a focusable field(BACK)--
--Non focusable Label field that indicates the name of the user--
--A horizontal field manager1 that contains 4 buttons--
--A horizontal field manager2 that contains 4 buttons--
--A horizontal field manager2 that contains 4 buttons--
==================================================== =================================
现在假设当前焦点在 BACK 按钮上,然后我向下滚动拨轮,焦点应该出现在 manager1 的第一个按钮上,当我再次向下滚动时,焦点应该出现在 manager2 的第一个按钮上,而不是 manager1 的第二个按钮上(因为它发生在设备上)
我的代码是:::
protected boolean trackwheelRoll(int amount, int status, int time)
{
focusIndex = this.getFieldWithFocusIndex();
System.out.println("focus index ::::::::::::::::"+focusIndex);
Field f;
if(focusIndex!=0)
{
if(amount==-1)
{
//move up
if(focusIndex>=0)
{
focusIndex = focusIndex-1;
f = getField(focusIndex);
f.setFocus();
}
}
if(amount==1)
{
//moving down
if(focusIndex<=3)
{
f = getField(++focusIndex);
f.setFocus();
}
}
}
return super.trackwheelRoll(amount, status, time);
}
即使此控件在模拟器上突然移动但在设备上也没有发生变化