从 GridView 发起的 ContextMenu
ContextMenu initiated from GridView
只是想知道是否有人可以帮助解决这个问题 - 我正在学习但无法弄清楚......
如果我使用上下文菜单注册一个 GridView 对象,如下所示:
registerForContextMenu(gridview);
如何确定菜单是从网格中的哪个视图 object/square 启动的?
非常感谢任何帮助
在onContextItemSelected()
方法中,您可以使用以下方法获取项目在Grid上的索引:
AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo();
int index = info.position;
然后使用此 index 获取您想要的一切:)
只是想知道是否有人可以帮助解决这个问题 - 我正在学习但无法弄清楚......
如果我使用上下文菜单注册一个 GridView 对象,如下所示:
registerForContextMenu(gridview);
如何确定菜单是从网格中的哪个视图 object/square 启动的?
非常感谢任何帮助
在onContextItemSelected()
方法中,您可以使用以下方法获取项目在Grid上的索引:
AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo();
int index = info.position;
然后使用此 index 获取您想要的一切:)