避免按一下按钮显示菜单 [英] avoid showing menu on button click

查看:169
本文介绍了避免按一下按钮显示菜单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的应用程序有一个按钮,点击该按钮时的上下文菜单弹出。我怎样才能避免在上下文菜单中显示?

 保护无效列出MakeMenu(菜单菜单,诠释上下文){
    menu.add(_imageMenuItem);
    super.makeMenu(菜单,背景);
}类ImageMenuItem扩展菜单项{
    ImageMenuItem(){
        超(登录屏幕,0,0);
    }
    公共布尔onMenu(int i)以{
        返回false;
    }    公共无效的run(){
        UIApplication的应用=(的UIApplication)getApplication();
        app.pushScreen(新LoginScreen());
    }
}


解决方案

您已经通过构造函数添加样式到ButtonField字段?

  ButtonField字段按钮=
    新ButtonField字段(文字,Field.H_CENTRE | ButtonField.CONSUME_CLICK);

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

解决方案

have you added style to the ButtonField via the constructor?

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

这篇关于避免按一下按钮显示菜单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆