@Override public boolean onContextItemSelected(MenuItem item) { final int position = ((AdapterView.AdapterContextMenuInfo) item.getMenuInfo()).position; final ListView view = (ListView) getTabHost().getCurrentView(); final Bookmark bookmark = ((BookmarksAdapter) view.getAdapter()).getItem(position); switch (item.getItemId()) { case OPEN_ITEM_ID: gotoBookmark(bookmark); return true; case EDIT_ITEM_ID: final Intent intent = new Intent(this, BookmarkEditActivity.class); OrientationUtil.startActivityForResult(this, intent, 1); // TODO: implement return true; case DELETE_ITEM_ID: myCollection.deleteBookmark(bookmark); if (myThisBookAdapter != null) { myThisBookAdapter.remove(bookmark); } if (myAllBooksAdapter != null) { myAllBooksAdapter.remove(bookmark); } if (mySearchResultsAdapter != null) { mySearchResultsAdapter.remove(bookmark); } return true; } return super.onContextItemSelected(item); }
@Override public boolean onCreateOptionsMenu(Menu menu) { super.onCreateOptionsMenu(menu); final MenuItem item = menu.add(0, 1, Menu.NONE, myResource.getResource("menu").getResource("search").getValue()); item.setOnMenuItemClickListener(this); item.setIcon(R.drawable.ic_menu_search); return true; }
@Override public boolean onMenuItemClick(MenuItem item) { switch (item.getItemId()) { case 1: return onSearchRequested(); default: return true; } }