0

大家好,我遇到了一个问题。我已经实现了ListField一个屏幕。在屏幕顶部,我用一个HorizontalFieldManager来握住TitleLabel and Two Butons. 我已经在列表字段的所有行上推送了一些屏幕。我的问题是,让假设当我在第 4 行并且我选择了我想要的内容然后当我单击按钮时,按钮工作但我在第 4 行实现的屏幕也出现了如何避免它。我在 Storm 9550 模拟器上测试它并使用 Blackberry eclipse plugin5.0 。我没有主意了,请帮帮我。

导航点击是这样的

protected boolean navigationClick(int status, int time) {

    selectListAndButton();
    return true;

}       

//这里是selectListAndButton方法

private selectListAndButton(){
 Field field = getFieldWithFocus().getLeafFieldWithFocus();
    if(field == backCustomButton){
        //Popped the active Screen

    }else if(field == saveCustomButton){
        //Saving some Data to the Database And pushing another Screen here
                    // problem comes here if i am at 2nd row of the listfield and selects  
                     something from there and clicked on the button the screen which was  

                     implemented at 2nd row also appears   

    }

    else if (_list.getSelectedIndex() == 0){    
        //Called a date picker

    }
            else if (_list.getSelectedIndex() == 1){    
        //Pushed some another screen 

    }

           else if (_list.getSelectedIndex() == ){  
        //Pushed some another screen 

    }
4

2 回答 2

1

您需要覆盖onTouchScreen调用特定功能取决于事件坐标和Field边界:

protected boolean touchEvent(TouchEvent message) {
   if (isTouchInside(message, saveCustomButton)) {
      save();
   } else {
      showNextScreen();
   }
}

private boolean isTouchInside(TouchEvent messages, Field field) {
   int eventCode = message.getEvent();       
   int touchX =  message.getX(1);
   int touchY =  message.getY(1);

   XYRect rect = field.getContentRect();

   return rect.contains(touchX, touchY);
}
于 2012-01-09T06:53:10.567 回答
0

我已经解决了。但发布的答案很晚。我只是放弃了使用的想法,ListField因为我没有太多要添加的行。所以我只是使用了这个小技巧,而不是使用ListField我用过HorizontalFieldManager的,它看起来像一个List所以一切正常。

谢谢欢呼:)

于 2012-05-10T03:49:11.173 回答