Floating Context Menu in Android
I am trying to create a floating Context Menu when long pressing a button. I have read all the answer but still, i am driving crazy with this. Here it is my code:

R.menu.menu.xml

    <?xml version="1.0" encoding="utf-8"?>
	    <menu
		  xmlns:android="http://schemas.android.com/apk/res/android">
		 
			<item android:id="@+id/MnuOpc1" android:title="Opcion1"
			       android:icon="@drawable/ic_launcher"></item>
			<item android:id="@+id/MnuOpc2" android:title="Opcion2"
			      android:icon="@drawable/ic_launcher"></item>
			<item android:id="@+id/MnuOpc3" android:title="Opcion3"
			      android:icon="@drawable/ic_launcher"></item>
		 
		</menu>


OnCreateContextMenu(...)

    	@Override
	public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
	    super.onCreateContextMenu(menu, v, menuInfo);
	    MenuInflater inflater = getMenuInflater();
	    inflater.inflate(R.menu.menu, menu);
	}

onContextItemSelected(...)

    @Override
	public boolean onContextItemSelected(MenuItem item) {
		Log.v("Hello...","I got the switch");  

		switch (item.getItemId()) {
		case R.id.MnuOpc1:
			Log.v("Hello...","Option 1"); 	
			return true;
		case R.id.MnuOpc2:
			Log.v("Hello...","Option 2"); 
			return true;
		default:
			return super.onContextItemSelected(item);
		}

I think all the code above is right but I am missing something when calling at registerForContextMenu:

        @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        
        setContentView(R.layout.main);
        linear = (LinearLayout) findViewById(R.layout.main);
        registerForContextMenu(linear);

I tried with "registerForContextMenu(getListView());" but it does not work, i am getting an error from Eclipse. What am I doing wrong? Thank you all
Floating Context Menu in Android
===

I am trying to create a floating Context Menu when long pressing a button. I have read all the answer but still, i am driving crazy with this. Here it is my code:

R.menu.menu.xml

    <?xml version="1.0" encoding="utf-8"?>
	    <menu
		  xmlns:android="http://schemas.android.com/apk/res/android">
		 
			<item android:id="@+id/MnuOpc1" android:title="Opcion1"
			       android:icon="@drawable/ic_launcher"></item>
			<item android:id="@+id/MnuOpc2" android:title="Opcion2"
			      android:icon="@drawable/ic_launcher"></item>
			<item android:id="@+id/MnuOpc3" android:title="Opcion3"
			      android:icon="@drawable/ic_launcher"></item>
		 
		</menu>


OnCreateContextMenu(...)

    	@Override
	public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
	    super.onCreateContextMenu(menu, v, menuInfo);
	    MenuInflater inflater = getMenuInflater();
	    inflater.inflate(R.menu.menu, menu);
	}

onContextItemSelected(...)

    @Override
	public boolean onContextItemSelected(MenuItem item) {
		Log.v("Hello...","I got the switch");  

		switch (item.getItemId()) {
		case R.id.MnuOpc1:
			Log.v("Hello...","Option 1"); 	
			return true;
		case R.id.MnuOpc2:
			Log.v("Hello...","Option 2"); 
			return true;
		default:
			return super.onContextItemSelected(item);
		}

I think all the code above is right but I am missing something when calling at registerForContextMenu:

        @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        
        setContentView(R.layout.main);
        linear = (LinearLayout) findViewById(R.layout.main);
        registerForContextMenu(linear);

I tried with "registerForContextMenu(getListView());" but it does not work, i am getting an error from Eclipse. What am I doing wrong? Thank you all