ListField 和按钮在同屏中焦点问题

发布于 2024-12-25 09:47:26 字数 1338 浏览 0 评论 0原文

大家好,我遇到了一个问题。我在一个屏幕中实现了一个 ListField 。在屏幕顶部,我使用了一个 Horizo​​ntalFieldManager 来容纳一个 TitleLabel 和两个按钮。我已经在列表字段的所有行上推送了一些屏幕。我的问题是,假设当我在第四行并且我选择了我想要的内容,然后当我单击按钮时,按钮起作用了,但是我在第四行实现的屏幕也出现了如何避免它。我正在 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 

    }

Hello all i stuck at one problem. I have implemented a ListField in one Screen. On top of the Screen i have used one HorizontalFieldManager to hold a TitleLabel and Two Butons. I have pushed some screen on all the rows of the listfield. My problem is, letSuppose when i am on 4th row and i have selected what i want then when i clicking on the button, then the button worked but the screen which i have implemented at 4th row also appear how to avoid it. I am testing it on storm 9550 simulator and using Blackberry eclipse plugin5.0 . I am running out of idea please help me .

navigation click is like this

protected boolean navigationClick(int status, int time) {

    selectListAndButton();
    return true;

}       

//And here is the selectListAndButton Method

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 

    }

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

漫雪独思 2025-01-01 09:47:26

您需要覆盖 ScreenonTouch 并根据事件坐标和 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);
}

You need to override onTouch for Screen and call specific functionality depend on event coordinates and Field boundaries:

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);
}
爱格式化 2025-01-01 09:47:26

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

谢谢干杯:)

I had solved it. but posting the answer late. I just dropped the idea of using ListField because i dont have so much rows to add. So i have just used the little trick rather using ListField i have used HorizontalFieldManager and its look like a List so everything working fine.

Thanks cheers :)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文