avoid showing menu on button click

会有一股神秘感。 提交于 2019-12-10 04:36:03

问题


In my application there is a button and when the button is clicked the context menu pops up. How can I avoid having the context menu show up?

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:


have you added style to the ButtonField via the constructor?

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


来源:https://stackoverflow.com/questions/4918778/avoid-showing-menu-on-button-click

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!