What version of Android are you developing for? Where are you setting the context menu listener? Do you by chance do that more than once?
---------------------------------------------------------------------- There are only 10 types of people in the world... Those who know binary and those who don't. ---------------------------------------------------------------------- On Thu, Jul 1, 2010 at 11:46 PM, Bender <abende...@googlemail.com> wrote: > Hi, > > I'm trying to make a context menu for a little notes application, and > it has some weird behaviour. My notes are categorized in.. well > categories. I'm using a ExpandableListView to show the categories > (groups) and notes (children). I have registered for context menu, and > what happens is the following: > > * When I click and hold a category, my context menu pops up which has > one option "delete". > * When I click delete, the category gets deleted and the context menu > disappears, but then a new context menu pops up which has also > "delete" in it, but it isnt clickable. The only way to close it is to > use the "back" button. > > I don't get why that second context menu pops up and how I can get rid > of it, I hope somebody here can help me. > > Here is my code, if additional code pieces please tell me. :) > > public void onCreateContextMenu(ContextMenu menu, View v, > ContextMenuInfo menuInfo) { > super.onCreateContextMenu(menu, v, menuInfo); > > ExpandableListView.ExpandableListContextMenuInfo info = > (ExpandableListView.ExpandableListContextMenuInfo) > menuInfo; > > int type = > ExpandableListView.getPackedPositionType(info.packedPosition); > > // Context menu for categories > if(type == ExpandableListView.PACKED_POSITION_TYPE_GROUP) { > menu.addSubMenu(0, CONTEXT_DELETE_CAT, 0, > R.string.delete); > > // Context menu for notes > } else if(type == > ExpandableListView.PACKED_POSITION_TYPE_CHILD) { > menu.addSubMenu(0, CONTEXT_DELETE_NOTE, 0, > R.string.delete); > } > } > > public boolean onContextItemSelected(MenuItem item) { > > ExpandableListContextMenuInfo info = > (ExpandableListContextMenuInfo) item.getMenuInfo(); > > switch(item.getItemId()) { > case CONTEXT_DELETE_CAT: > long categoryId = info.id; > db.categories.deleteWithNotes(categoryId); > mAdapter.notifyDataSetChanged(); > fillView(); > return true; > case CONTEXT_DELETE_NOTE: > long noteId = info.id; > db.notes.delete(noteId); > fillView(); > > getExpandableListView().expandGroup(mOpenedCategory); > return true; > default: > return super.onContextItemSelected(item); > } > } > > -- > 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<android-beginners%2bunsubscr...@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