@Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) { MenuInflater inflater = mCoolReader.getMenuInflater(); menu.clear(); inflater.inflate( mList.isShortcutMode() ? R.menu.cr3_bookmark_shortcut_context_menu : R.menu.cr3_bookmark_context_menu, menu); AdapterContextMenuInfo mi = (AdapterContextMenuInfo) menuInfo; if (mi != null) selectedItem = mi.position; Bookmark bm = mList.getSelectedBookmark(); menu.setHeaderTitle(getContext().getString(R.string.context_menu_title_bookmark)); for (int i = 0; i < menu.size(); i++) { MenuItem menuItem = menu.getItem(i); if (menuItem.getItemId() == R.id.bookmark_shortcut_goto || menuItem.getItemId() == R.id.bookmark_edit || menuItem.getItemId() == R.id.bookmark_delete) menuItem.setEnabled(bm != null); if (menuItem.getItemId() == R.id.bookmark_edit) menuItem.setEnabled( bm != null && (bm.getType() == Bookmark.TYPE_COMMENT || bm.getType() == Bookmark.TYPE_CORRECTION)); menuItem.setOnMenuItemClickListener( new OnMenuItemClickListener() { public boolean onMenuItemClick(MenuItem item) { onContextItemSelected(item); return true; } }); } }
@Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) { MenuInflater inflater = mCoolReader.getMenuInflater(); inflater.inflate(R.menu.cr3_bookmark_shortcut_context_menu, menu); AdapterContextMenuInfo mi = (AdapterContextMenuInfo) menuInfo; if (mi != null) selectedItem = mi.position; menu.setHeaderTitle(getContext().getString(R.string.context_menu_title_bookmark)); for (int i = 0; i < menu.size(); i++) { menu.getItem(i) .setOnMenuItemClickListener( new OnMenuItemClickListener() { public boolean onMenuItemClick(MenuItem item) { onContextItemSelected(item); return true; } }); } }