My question is similar to this one: ListView: disabling clicking/focus
However, I don't want to disable the default onClick, just the long click. I've registered my ListView for context menu creation, and I want to disable it for a header element (or at least change its behavior). How would I go about this?
Thanks!
Figured it out! It wasn't obvious that the menuInfo was necessarily an AdapterContextMenuInfo (which has position).
@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
super.onCreateContextMenu(menu, v, menuInfo);
MenuInflater inflater = getMenuInflater();
if (((AdapterContextMenuInfo)menuInfo).position == 1) {
inflater.inflate(R.menu.foo1, menu);
return;
}
inflater.inflate(R.menu.foo2, menu);
}