Clicking the more icon (3 vertical dots anchored to the right of the list item) opens up a context menu in Google Music:
I'm trying to recreate this with what I'm guessing is a context menu. Documentation says:
If your activity uses a ListView or GridView and you want each item to provide the same context menu, register all items for a context menu by passing the ListView or GridView to registerForContextMenu().
But I still want the list item itself clickable. I just want a context menu to show up when the user clicks on the more icon like it does in Google Music.
So I tried this:
@Override
public void onMoreClicked(ArtistsListItem item, int position, View imageButton) {
registerForContextMenu(imageButton);
}
onMoreClicked is just part of a custom listener I made to receive onClick callbacks from the list's adapter.
registerForContextMenu is called, but the fragment's onCreateContextMenu method is never invoked:
@Override
public void onCreateContextMenu(ContextMenu menu, View view, ContextMenu.ContextMenuInfo info) { //this method is never called
super.onCreateContextMenu(menu, view, info);
android.view.MenuInflater inflater = mActivity.getMenuInflater();
inflater.inflate(R.menu.artist_list_menu, menu);
}
I ran some breakpoints to check if it was running but it never did. I did the same with the activity's onCreateContextMenu (the registerForContextMenu's class is the fragment, but just to be sure I did it that way) and no dice either.
I'm using ActionBarSherlock, I don't know if that makes a difference but I guess it's worth noting.
Does anyone have an idea what is going on here?