Reputation: 15529
When using a custom adapter, with a BindView method, is it possible to obtain the ContextMenu object associated with the view being bound?
I would like to change the items displayed in the context menu depending on the item being displayed and I can't find a way to obtain the corresponding ContextMenu.
Thanks
Upvotes: 1
Views: 1286
Reputation: 1368
You can get the position and other details of the item from the menuInfo:
@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
final AdapterContextMenuInfo adapterMenuInfo = (AdapterContextMenuInfo) menuInfo;
int pos = adapterMenuInfo.position;
// Do what you will
}
Upvotes: 3