2010-04-30 74 views
1

我正在黑莓曲线上工作8300trackroll不工作,因为我想或期望做,黑莓

我已经在主屏幕添加了一些组件,现在我要当轨迹球向上移动垂直移动焦点或向下移动,并在轨道轮向左或向右移动时水平移动焦点。

============================================== ====================================

--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); 
} 

即使突然在模拟器 但对设备没有变化发生

回答

2

这种控制移动尝试重写[navigationMovement] [1]的方法,而不是trackwheelRoll - 你可以访问“dx”和“dy”参数,这样你就可以判断它们是在上/下还是左右摇摆。由于没有更多的拨轮设备,trackwheelRoll方法有点陈旧。

[1]:http://www.blackberry.com/developers/docs/5.0.0api/net/rim/device/api/ui/Manager.html#navigationMovement(int,INT,INT,INT)

+0

你的想法工作! 我试过导航运动 我意识到拨轮不适用于有空间垫或轨迹球的设备 – Swati 2010-05-01 06:17:38

1
protected boolean navigationMovement(int dx, int dy, int status, int time) 
{ 
    Field f; 
    int index; 
    focusIndex = this.getFieldWithFocusIndex(); 
    if(focusIndex==1) 
    { 
     f = getField(focusIndex); 

     Manager m = (Manager)f; 
     index = m.getFieldWithFocusIndex(); 
     if(dx==-1) 
     { 
      index = index--; 
      if(index>=0) 
       { 
       f = m.getField(index); 
       f.setFocus(); 
       } 
     } 
     if(dy==-1) 
     { 
      index = index-3; 
      if(index>=0) 
       { 
       f = m.getField(index); 
       f.setFocus(); 
       } 
     } 
     if(dx==1) 
     { 
      index = index++; 
      if(index<=19) 
       { 
       f = m.getField(index); 
       f.setFocus(); 
       } 
     } 
     if(dy==1) 
     { 
      index = index+3; 
      if(index<=19) 
       { 
       f = m.getField(index); 
       f.setFocus(); 
       } 
     } 
    } 
    return super.navigationMovement(dx, dy, status, time); 
} 
相关问题