Check value to disable / enable context menu item (android)

There is a ListView in my application. A long press on an item displays the "Context Menu". I want to check the data identifier, and then set disable / enable to my Items menu. I cannot find the getMenuInfo () function 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);                       
}
+3
source share
1 answer
AdapterView.AdapterContextMenuInfo info=(AdapterView.AdapterContextMenuInfo)menuInfo();

Then info.idis _IDany item that has been long in your ListView.

+4
source

Source: https://habr.com/ru/post/1716179/


All Articles