Q:

ANDROID: Context Menu does not show

I have an activity.
In the activity i have this in onCreate:
@Override
   public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);

      settings = (GlobalSettings) getApplication();
      mappingServiceContent = settings.getMappingServiceContent();
      mapView = settings.getMapView();
      if (mapView == null)
      {
          mapView = new RMapView(RCoordinateSystemFactory.createFromCrsCode("EPSG:2170"));
          settings.setMapView(mapView);
          settings.isFirstTime = true;
      }
      else
      {
          settings.isFirstTime = false;
      }

      RelativeLayout relativeLayout = new RelativeLayout(this);
      myMapView = new MyMapView(this, this.getWindowManager(), settings);  
      zoomControls = new ZoomControls(this);
      registerForContextMenu(myMapView );

      RelativeLayout.LayoutParams mapViewLayoutParams = new RelativeLayout.LayoutParams
        (RelativeLayout.LayoutParams.FILL_PARENT,RelativeLayout.LayoutParams.FILL_PARENT );
      relativeLayout.addView(myMapView, mapViewLayoutParams);

      RelativeLayout.LayoutParams zoomControlsLayoutParams = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT );
        zoomControlsLayoutParams.addRule (RelativeLayout.ALIGN_PARENT_BOTTOM);
        zoomControlsLayoutParams.addRule(RelativeLayout.CENTER_HORIZONTAL);
      relativeLayout.addView(zoomControls,zoomControlsLayoutParams);

      zoomControls.setOnZoomInClickListener(new View.OnClickListener() {
          public void onClick(final View v) {
            myMapView.ZoomIn();
          }
        });

        zoomControls.setOnZoomOutClickListener(new View.OnClickListener() {
          public void onClick(final View v) {
            myMapView.ZoomOut();
          }
        });

      myMapView.setClickable(true);
      myMapView.setEnabled(true);

      setContentView(relativeLayout);
   }

MyMapView is a View created like this:
public class MyMapView extends View

In my activity i have added:
   @Override  
   public void onCreateContextMenu(ContextMenu menu, View v,ContextMenuInfo menuInfo) {  
       super.onCreateContextMenu(menu, v, menuInfo);  
       menu.setHeaderTitle("Context Menu");  
       menu.add(0, v.getId(), 0, "Action 1");  
       menu.add(0, v.getId(), 0, "Action 2");  
   }

But the context menu never gets fired if i hold my finger on the screen.
I must be missing something ... can some1 please help me out?
regards.

A:

Maybe you are just missing sg. AFAIK your code should work. If you cannot get a solution, try AlertDialog, it is the same (or looks and behaves the same, idk).
    final CharSequence[] items = {"Red", "Green", "Blue"};
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle("Pick a color");
builder.setItems(items, new DialogInterface.OnClickListener() {    
 public void onClick(DialogInterface dialog, int item) {        
    Toast.makeText(getApplicationContext(), items[item], Toast.LENGTH_SHORT).show();     
    }
 });
AlertDialog alert = builder.create();

The code is from here

