@Override public boolean onContextItemSelected(MenuItem menuItem) { ExpandableListContextMenuInfo info = (ExpandableListContextMenuInfo) menuItem.getMenuInfo(); int type = ExpandableListView.getPackedPositionType(info.packedPosition); if (type == ExpandableListView.PACKED_POSITION_TYPE_CHILD) { int group = ExpandableListView.getPackedPositionGroup(info.packedPosition); int child = ExpandableListView.getPackedPositionChild(info.packedPosition); HistoryItem item = (HistoryItem) getExpandableListAdapter().getChild(group, child); switch (menuItem.getItemId()) { case MENU_OPEN_IN_TAB: doNavigateToUrl(item.getUrl(), true); break; case MENU_COPY_URL: ApplicationUtils.copyTextToClipboard( this, item.getUrl(), getString(R.string.Commons_UrlCopyToastMessage)); break; case MENU_SHARE: ApplicationUtils.sharePage(this, item.getTitle(), item.getUrl()); break; case MENU_DELETE_FROM_HISTORY: BookmarksProviderWrapper.deleteHistoryRecord(getContentResolver(), item.getId()); fillData(); break; default: break; } } return super.onContextItemSelected(menuItem); }