避免在点击按钮时显示菜单

时间:2011-02-07 07:00:12

标签: blackberry blackberry-simulator blackberry-jde

在我的应用程序中有一个按钮,单击该按钮时会弹出上下文菜单。如何避免显示上下文菜单?

protected void makeMenu(Menu menu, int context){
    menu.add(_imageMenuItem);
    super.makeMenu(menu, context);
}

class ImageMenuItem extends MenuItem {      
    ImageMenuItem() {
        super("Login Screen", 0, 0);            
    }
    public boolean onMenu(int i) {
        return false;
    }

    public void run() {
        UiApplication app = (UiApplication) getApplication();
        app.pushScreen(new LoginScreen());
    }
}

1 个答案:

答案 0 :(得分:16)

您是否通过构造函数向ButtonField添加了样式?

ButtonField button = 
    new ButtonField("text", Field.H_CENTRE|ButtonField.CONSUME_CLICK);