Source:
<code>public boolean onOptionsItemSelected(MenuItem item) { Intent i; switch(item.getItemId()) { case R.id.trackdetail_menu_save: save(); finish(); break; case R.id.trackdetail_menu_cancel: finish(); break; case R.id.trackdetail_menu_display: boolean useOpenStreetMapBackground = PreferenceManager.getDefaultSharedPreferences(this).getBoolean( OSMTracker.Preferences.KEY_UI_DISPLAYTRACK_OSM, OSMTracker.Preferences.VAL_UI_DISPLAYTRACK_OSM); if (useOpenStreetMapBackground) { i = new Intent(this, DisplayTrackMap.class); } else { i = new Intent(this, DisplayTrack.class); } i.putExtra(Schema.COL_TRACK_ID, trackId); startActivity(i); break; case R.id.trackdetail_menu_export: new ExportToStorageTask(this, trackId).execute(); SimpleAdapter adapter = ((SimpleAdapter) lv.getAdapter()); @SuppressWarnings("unchecked") Map<String, String> data = (Map<String, String>) adapter.getItem(adapter.getCount()-1); data.put(ITEM_VALUE, DateFormat.getDateTimeInstance().format(new Date(System.currentTimeMillis()))); adapter.notifyDataSetChanged(); break; case R.id.trackdetail_menu_share: new ExportAndShareTask(this, trackId).execute(); <START> SimpleAdapter adapter1 = ((SimpleAdapter) lv.getAdapter()); <END> @SuppressWarnings("unchecked") Map<String, String> data1 = (Map<String, String>) adapter1.getItem(adapter1.getCount()-1); data1.put(ITEM_VALUE, DateFormat.getDateTimeInstance().format(new Date(System.currentTimeMillis()))); adapter1.notifyDataSetChanged(); break; case R.id.trackdetail_menu_osm_upload: i = new Intent(this, OpenStreetMapUpload.class); i.putExtra(Schema.COL_TRACK_ID, trackId); startActivity(i); break; } return super.onOptionsItemSelected(item); }</code><technical_language>mind avoiding names adapter1, prefer adapter for instance (see done for other menus)</technical_language>

Target:
public boolean onOptionsItemSelected(MenuItem item) { Intent i; SimpleAdapter adapter; @SuppressWarnings("unchecked") Map<String, String> data; switch(item.getItemId()) { case R.id.trackdetail_menu_save: save(); finish(); break; case R.id.trackdetail_menu_cancel: finish(); break; case R.id.trackdetail_menu_display: boolean useOpenStreetMapBackground = PreferenceManager.getDefaultSharedPreferences(this).getBoolean( OSMTracker.Preferences.KEY_UI_DISPLAYTRACK_OSM, OSMTracker.Preferences.VAL_UI_DISPLAYTRACK_OSM); if (useOpenStreetMapBackground) { i = new Intent(this, DisplayTrackMap.class); } else { i = new Intent(this, DisplayTrack.class); } i.putExtra(Schema.COL_TRACK_ID, trackId); startActivity(i); break; case R.id.trackdetail_menu_export: new ExportToStorageTask(this, trackId).execute(); adapter = ((SimpleAdapter) lv.getAdapter()); data = (Map<String, String>) adapter.getItem(adapter.getCount()-1); data.put(ITEM_VALUE, DateFormat.getDateTimeInstance().format(new Date(System.currentTimeMillis()))); adapter.notifyDataSetChanged(); break; case R.id.trackdetail_menu_share: new ExportAndShareTask(this, trackId).execute(); adapter = ((SimpleAdapter) lv.getAdapter()); data = (Map<String, String>) adapter.getItem(adapter.getCount()-1); data.put(ITEM_VALUE, DateFormat.getDateTimeInstance().format(new Date(System.currentTimeMillis()))); adapter.notifyDataSetChanged(); break; case R.id.trackdetail_menu_osm_upload: i = new Intent(this, OpenStreetMapUpload.class); i.putExtra(Schema.COL_TRACK_ID, trackId); startActivity(i); break; } return super.onOptionsItemSelected(item); }