java - Get Item ID From Context Menu -
hey people, trying id of item, in case table row, long pressed bring context menu. code far.
@override public void oncreatecontextmenu(contextmenu menu, view v, contextmenuinfo menuinfo) { super.oncreatecontextmenu(menu, v, menuinfo); menuinflater inflater = getmenuinflater(); inflater.inflate(r.menu.context_menu, menu); } @override public boolean oncontextitemselected(menuitem item) { adaptercontextmenuinfo info = (adaptercontextmenuinfo) item.getmenuinfo(); switch (item.getitemid()) { case r.id.delete: deleteitem(id); //id of item should passed method deleteitem toast.maketext(this, "delete", toast.length_long).show(); return true; default: return super.oncontextitemselected(item); } }
as can see need id of table row pass method. have tried using info null. missing here you'll able point me in right direction. thanks.
check adaptercontextmenuinfo.id
field.
Comments
Post a Comment