Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/blackberry/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Blackberry 同一屏幕中的列表字段和按钮焦点问题_Blackberry_Button_Listfield - Fatal编程技术网

Blackberry 同一屏幕中的列表字段和按钮焦点问题

Blackberry 同一屏幕中的列表字段和按钮焦点问题,blackberry,button,listfield,Blackberry,Button,Listfield,大家好,我一直在解决一个问题。我在一个屏幕中实现了一个列表字段。在屏幕顶部,我使用了一个HorizontalFieldManager来保存一个标题标签和两个Buton。我在列表字段的所有行上都按了一些屏幕。我的问题是,假设我在第四行,并且我已经选择了我想要的,然后当我点击按钮时,按钮工作了,但是我在第四行实现的屏幕也显示了如何避免它。我正在storm 9550模拟器上测试它,并使用Blackberry eclipse插件5.0。我快没主意了,请帮帮我 导航点击是这样的 protected boo

大家好,我一直在解决一个问题。我在一个屏幕中实现了一个
列表字段
。在屏幕顶部,我使用了一个
HorizontalFieldManager
来保存一个
标题标签和两个Buton
。我在列表字段的所有行上都按了一些屏幕。我的问题是,假设我在第四行,并且我已经选择了我想要的,然后当我点击按钮时,按钮工作了,但是我在第四行实现的屏幕也显示了如何避免它。我正在storm 9550模拟器上测试它,并使用Blackberry eclipse插件5.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 

    }

您需要为
屏幕
覆盖
onTouch
,并根据事件坐标和
字段
边界调用特定功能:

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

我已经解决了。但是迟交答案。我刚刚放弃了使用
ListField
的想法,因为我没有那么多行要添加。因此,我只是使用了这个小技巧,而不是使用了
ListField
我使用了
HorizontalFieldManager
,它看起来像一个
列表
,所以一切正常


谢谢干杯:)

什么是
isTouchInside()
方法你能进一步研究一下它吗?为什么它不能与
navigationclick一起工作?默认情况下,touchEvent方法将调用navigationclick。他们这样做是为了与旧代码兼容。这工作得很好,除了在控件/屏幕中重写navigationClick方法。我没有调试你的代码,但看起来触摸事件没有为你的按钮调用聚焦,或者它在UI线程队列和导航中。在聚焦获得它之前单击进程。好的,一旦它对我有效,我会给你一个kudo和+1,以解释我thanx。。。