/** actions for the context menu */ @Override public boolean onContextItemSelected(MenuItem item) { AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo(); int id = (int) getListAdapter().getItemId(info.position); // sets an alarm for the selected stop switch (item.getItemId()) { case SET_STOP_OPTION: Intent i = new Intent(getApplicationContext(), ConfirmationPage.class); HashMap<String, String> busItem = locationList.get(id); DataFetcher df = new DataFetcher(); try { BusStop b = df.getStopById(Integer.parseInt(busItem.get("stopID").split("_")[1])); i.putExtra("busstop", b); i.putExtra("busroute", busItem.get("routeID")); i.putExtra("busroutedesc", busItem.get("routeDesc")); startActivity(i); finish(); // if an exception occurs, nothing happens (for now). } catch (NumberFormatException e) { Log.v(TAG, "Error parsing stop id!"); e.printStackTrace(); } catch (IOException e) { Log.v(TAG, "Error fetching info!"); e.printStackTrace(); } break; // removes the selected stop from the list case REMOVE_STOP_OPTION: HashMap<String, String> itemToRemove = locationList.get(id); mBusDbHelper.open(); mBusDbHelper.deleteDest(itemToRemove.get("routeID"), itemToRemove.get("stopID")); mBusDbHelper.close(); locationList.remove(id); listAdapter.notifyDataSetChanged(); break; case CANCEL: break; default: break; } return true; }