onContextItemSelected never called using a Dialog with a ListView

android

Solution

I'm not sure why what you have isn't working, but you could try adding a listener to your menuItem instead: setOnMenuItemClickListener. At least that would tell you that your context menu item was being selected.

Problem

I'm creating a simple dialog with a ListView on it. I want to be able to access a context menu on it. Here's the basic code I've: ``` <On CreateDialog> listViewSongs=(ListView) layout.findViewById(R.id.ListView_Songs); listViewSongs.setAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, drawingPanel.metronome.getSongNames())); registerForContextMenu(listViewSongs); ``` Then I just add a simple item: ``` @Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) { super.onCreateContextMenu(menu, v, menuInfo); menu.setHeaderTitle("Sample Context Menu"); menu.add(0, MENU_EDIT_SONG, 0, "Edit"); } ``` And finally I override the onContextItemSelected: ``` @Override public boolean onContextItemSelected(MenuItem item) { super.onContextItemSelected(item); editSong(); return true; } ``` So my problem is that when I longpress the listview I got the context menu, but after clicking the only option on it, it never calls onContextItemSelected :( Any help? PS: I've tried also to override onMenuItemSelected, onOptionsItemSelected, but I got the same result :\ never got called.

Original source