ContextMenu的点击事件
@Override public boolean onContextItemSelected(MenuItem item) { switch (item.getItemId()){ case 101: Toast.makeText(this, "我点击了新建", Toast.LENGTH_SHORT).show(); break; case 102: Toast.makeText(this, "我点击了复制", Toast.LENGTH_SHORT).show(); break; case 103: Toast.makeText(this, "我点击了剪切", Toast.LENGTH_SHORT).show(); break; case 104: Toast.makeText(this, "我点击了删除", Toast.LENGTH_SHORT).show(); break; } return super.onContextItemSelected(item); }
如上,ContextMenu既然是长按某个item,那我如何拿到我要操作的那个Item对象,或者说如何确定ListView的position呢?