Hi, I have a ListView which is populated with items and I would like to be able to modify the resulting menu based on some information fetched from the Cursor used to create the row. Is there a preferred approach for storing a boolean or flag associate with the row? Eg. should it be in the View?
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) { ListView listView = (ListView) v; Also listView.getSelectedItem() seems to return null, listView.getSelectedItemId() gives a very negative number and listView.getSelectedView() is null too. I thought that the mSelectedItem would be populated when creating the context menu. Or it could be some typo somewhere... :) Regards, Julius. On 26/05/2009, at 11:48 AM, Mark Murphy wrote: > > Sikus wrote: >> Is there any way how can I find out item selected in >> onCreateContextMenu method? I need show or hide items in the context >> menu according to item in ListView. > > getSelectedItem(), getSelectedItemId(), and getSelectedView() should all > work, called on your ListView. > > -- > Mark Murphy (a Commons Guy) > http://commonsware.com | http://twitter.com/commonsguy > > Android Development Wiki: http://wiki.andmob.org > > --~--~---------~--~----~------------~-------~--~----~ > You received this message because you are subscribed to the Google > Groups "Android Beginners" group. > To post to this group, send email to android-beginners@googlegroups.com > To unsubscribe from this group, send email to > android-beginners-unsubscr...@googlegroups.com > For more options, visit this group at > http://groups.google.com/group/android-beginners?hl=en > -~----------~----~----~----~------~----~------~--~--- > -- You received this message because you are subscribed to the Google Groups "Android Beginners" group. NEW! Try asking and tagging your question on Stack Overflow at http://stackoverflow.com/questions/tagged/android To unsubscribe from this group, send email to android-beginners+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-beginners?hl=en