0
ContextMenuInfo.id和item.getItemId在回調中的區別onContextItemSelected()?回調函數onContextItemSelected()中的ContextMenuInfo.id和item.getItemId有什麼區別?
如何在我的AVD中顯示ContextMenu?謝謝!!
@Override
public void onCreateContextMenu(ContextMenu menu, View v,
ContextMenuInfo menuInfo) {
super.onCreateContextMenu(menu, v, menuInfo);
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.context_menu, menu);
}
@Override
public boolean onContextItemSelected(MenuItem item) {
AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo();
switch (item.getItemId()) {
case R.id.edit:
editNote(info.id);
return true;
case R.id.delete:
deleteNote(info.id);
return true;
default:
return super.onContextItemSelected(item);
}
}
謝謝!那麼如何更改** menuInfo **中的info.id? – Sam