注册一个上下文菜单:
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).
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).
别设为disable,设为"可用但不可见"试试
简单地说,就是 onCreateContextMenu 产生的菜单,点击后,选中的菜单必须按回车才会消失,不能自动让他消失
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 好像不调用啊
嗯,BUG很多,或者说,文档不全。感觉写android这批人时间太紧张了,来不及系统的规划