注册一个上下文菜单:
 
     registerForContextMenu(this.restaurantListView); 
重载:public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo);public boolean onContextItemSelected(MenuItem item)
在onContextItemSelected(MenuItem item) 里面PopupWindow 一个窗口;结果选中的菜单中总是在 PopupWindow的前面显示,
怎么也消除不了使用
 item.setEnabled(false);
 item.setVisible(false);
也不起作用。各位有木有碰到啊,悲催的android 还在注释里面写着,是不是……Sets whether the menu item is enabled. Disabling a menu item will not allow it to be invoked via its shortcut. The menu item will still be visible.Sets the visibility of the menu item. Even if a menu item is not visible, it may still be invoked via its shortcut (to completely disable an item, set it to invisible and disabled).

解决方案 »

  1.   

    "说你禁用一个菜单将不允许快捷方式调用"
    别设为disable,设为"可用但不可见"试试
      

  2.   


    简单地说,就是 onCreateContextMenu 产生的菜单,点击后,选中的菜单必须按回车才会消失,不能自动让他消失
      

  3.   

    public void onContextMenuClosed (Menu menu) 
    Since: API Level 1 
    This hook is called whenever the context menu is being closed (either by the user canceling the menu with the back/menu button, or when an item is selected).Parameters
    menu  The context menu that is being closed.  感觉这里面有个BUG,when an item is selected  ,onContextMenuClosed 好像不调用啊
      

  4.   

    建议楼主:不要使用android自带的menu了,自带的menu有很大的局限性,就拿换个item背景色来说吧,就费劲,所以建议你自己写一个类似menu的popwindow,就完全可以实现你的功能啊,而且还好控制!!
      

  5.   


    嗯,BUG很多,或者说,文档不全。感觉写android这批人时间太紧张了,来不及系统的规划
      

  6.   

    不使用  menu.addSubMenu(^^)使用 super.getMenuInflater().inflate(R.menu……问题解决了