Why don't you override the onCreateContextMenu directly in
MapActivity ?
On Dec 26, 10:15 am, "[email protected]" <[email protected]>
wrote:
> hi all
> I want to create a context menu when LongClick is hitted. As
> result mapview is opened successfully; but the LongClick got no
> response. Would you like to give me a hand how to solve it? Below is
> the complete code. Thank you very much.
>
> package android.demo;
> import com.google.android.maps.MapActivity;
> import android.os.Bundle;
> import com.google.android.maps.MapView;
> import android.view.ContextMenu;
> import android.view.View;
> import android.util.*;
> public class demo extends MapActivity {
> /** Called when the activity is first created. */
> MapView mapView;
> @Override
> public void onCreate(Bundle savedInstanceState) {
> super.onCreate(savedInstanceState);
> setContentView(R.layout.main);
> mapView = (MapView) findViewById(R.id.mapview1);
> // We also want to show context menu for longpressed items in
> the gallery
> //init the map view
>
> mapView.setOnLongClickListener(new View.OnLongClickListener(){
>
> public boolean onLongClick(View v) {
> mapView.showContextMenu();
> return true;
> }
>
> });
>
> mapView.setOnCreateContextMenuListener(new
> View.OnCreateContextMenuListener() {
> public void onCreateContextMenu(ContextMenu menu, View v,
> ContextMenu.ContextMenuInfo menuInfo) {
> menu.setHeaderTitle("Menu");
> menu.add(0, 1, 0, "Add");
> menu.add(0, 2, 0, "Delete");
> menu.add(0, 3, 0, "Edit");
> }
> });
>
> registerForContextMenu(mapView);
>
> }
>
> @Override
> protected boolean isRouteDisplayed() {
> // TODO Auto-generated method stub
> return false;
> }
>
> }
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---