In my application has a ListView. When long press on item the "Context Menu" will appear. I want to check the data ID, then set disable/enable to my Context Menu "Items". I can not find out the function like getMenuInfo() or something like this.
@Override
public void onCreateContextMenu(ContextMenu menu , View v, ContextMenuInfo menuInfo)
{
super.onCreateContextMenu(menu, v, menuInfo);
menu.add(0, ADD_FAVORITE_ID, 0, "Check");
menu.add(0, ADD_FAVORITE_ID, 0, "UnCheck").setEnabled(false);
}
AdapterView.AdapterContextMenuInfo info=(AdapterView.AdapterContextMenuInfo)menuInfo();
Then, info.id is the _ID of whatever item was long-tapped in your ListView.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With