@Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) { super.onCreateContextMenu(menu, v, menuInfo); if (v.getId() == android.R.id.list) { AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) menuInfo; Station station = (Station) getListAdapter().getItem(info.position); menu.setHeaderTitle(Formatteur.formatterChaine(station.name)); menu.add(Menu.NONE, R.id.supprimerFavori, 0, getString(R.string.suprimerFavori)); } }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.listvelofavoris); getActivityHelper() .setupActionBar( R.menu.liststation_favoris_menu_items, R.menu.holo_liststation_favoris_menu_items); setListAdapter(new VeloAdapter(getApplicationContext(), stations)); ListView listView = getListView(); listView.setOnItemClickListener( new AdapterView.OnItemClickListener() { @SuppressWarnings({"unchecked"}) public void onItemClick(AdapterView<?> adapterView, View view, int position, long id) { VeloAdapter veloAdapter = (VeloAdapter) ((AdapterView<ListAdapter>) adapterView).getAdapter(); Station station = veloAdapter.getItem(position); String lat = Double.toString(station.getLatitude()); String lon = Double.toString(station.getLongitude()); Uri uri = Uri.parse( "geo:0,0?q=" + Formatteur.formatterChaine(station.name) + "+@" + lat + ',' + lon); startActivity(new Intent(Intent.ACTION_VIEW, uri)); } }); listView.setTextFilterEnabled(true); registerForContextMenu(listView); new GetStations().execute((Void) null); // Look up the AdView as a resource and load a request. ((AdView) this.findViewById(R.id.adView)).loadAd(new AdRequest()); }