title: How to inflate Context Menu from Onclickitem?
body: <p>I am trying to inflate a Context Menu from this code. The program runs, however, whenever I click on an item nothing happens. This is the code I am using. Could you please help me figure out what's wrong? The name of the menu I am trying to open is called "testmenu".</p>
  
  <pre><code>package com.carouseldemo.main;
  
  import com.carouseldemo.controls.Carousel;
  import com.carouseldemo.controls.CarouselAdapter;
  import com.carouseldemo.controls.CarouselItem;
  import com.carouseldemo.controls.CarouselAdapter.OnItemClickListener;
  import com.carouseldemo.controls.CarouselAdapter.OnItemSelectedListener;
  import com.carouseldemo.main.R;
  
  import android.app.Activity;
  import android.media.MediaPlayer;
  import android.os.Bundle;
  import android.view.ContextMenu;
  import android.view.ContextMenu.ContextMenuInfo;
  import android.view.Gravity;
  import android.view.LayoutInflater;
  import android.view.MenuInflater;
  import android.view.View;
  import android.view.View.OnClickListener;
  import android.view.ViewGroup;
  
  import android.widget.TextView;
  import android.widget.Toast;
  
  
  public class MainActivity extends Activity implements OnClickListener {
   @Override
    public void onCreateContextMenu (ContextMenu menu, View v, ContextMenuInfo menuInfo) {
      super.onCreateContextMenu(menu, v, menuInfo);
      MenuInflater inflater = getMenuInflater();
      inflater.inflate(R.menu.testmenu, menu);
    }
  
  
  /** Called when the activity is first created. */
  
  @Override
  public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.main);
  
  
  
  
      MediaPlayer mp = MediaPlayer.create(this, R.raw.radio);
  
      mp.start();
      Carousel carousel = (Carousel)findViewById(R.id.carousel);
      carousel.setOnItemClickListener(new OnItemClickListener(){
  
          public void onItemClick(CarouselAdapter&lt;?&gt; parent, View view,
                  int position, long id) {    
              registerForContextMenu(view);
              openContextMenu(view);
  
  
          }
  
          @Override
          public void onCreateContextMenu(ContextMenu menu, View v,
                  CoTell me please, whenntextMenuInfo menuInfo) {
              // TODO Auto-generated method stub
  
          }
  
  
  
      });
  
  
  
  
      carousel.setOnItemSelectedListener(new OnItemSelectedListener(){
  
          public void onItemSelected(CarouselAdapter&lt;?&gt; parent, View view,
                  int position, long id) {
  
  
  
              final TextView txt = (TextView)(findViewById(R.id.selected_item));
  
              switch(position){
              case 0:
                  txt.setText("Power Source International ");
                  break;
              case 1:
                  txt.setText("Power Source International");
                  break;
              case 2:
                  txt.setText("Power Source International");
                  break;
              case 3:
                  txt.setText("Power Source International.");
                  break;
              case 4:
                  txt.setText("Power Source International");
              case 5:
                  txt.setText("Power Source InternationalPower Source InternationalPower Source InternationalPower Source InternationalPower Source InternationalPower Source InternationalPower Source InternationalPower Source InternationalPower Source InternationalPower Source InternationalPower Source InternationalPower Source InternationalPower Source InternationalPower Source International");
                  break;
              }
  
          }
  
          public void onNothingSelected(CarouselAdapter&lt;?&gt; parent) {
          }
  
      }
      );
  
  }
  
  @Override
  public void onClick(View v) {
      // TODO Auto-generated method stub
  
  }
  
  
  
  }
  </code></pre>
  
  <p>If it will help, here is the code for the menu as well.</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;menu xmlns:android="http://schemas.android.com/apk/res/android"&gt;
  &lt;item android:id="@+id/new_game"
        android:icon="@drawable/cat"
        android:title="@string/new_game"
        android:showAsAction="ifRoom" android:checkable="true" android:enabled="true"         android:visible="true"/&gt;
  &lt;item android:id="@+id/help"
        android:icon="@drawable/cat"
        android:title="@string/help" /&gt;
  </code></pre>
  
  <p></p>
  
  <p>How do I open this menu in my activity? The menu will not come up when I click an item.</p>