Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我知道这是可能的,因为我以前做过,但是我丢失了代码。我想从触摸事件中打开菜单。我需要写什么才能打开它?我真的不知道了。
您需要覆盖onCreateContextMenu(ContextMenu, View, ContextMenu.ContextMenuInfo)并onContextItemSelect()处于活动状态。如果您希望它出现在长按上,请调用registerForContextMenu(View). 如果您想在单击任何视图时手动显示它,请调用openContextMenu()onClick()。
onCreateContextMenu(ContextMenu, View, ContextMenu.ContextMenuInfo)
onContextItemSelect()
registerForContextMenu(View)
openContextMenu()