title: Android: Listview long hold context menu issue
body: <p>I'm trying to open a context menu after long holding the a listview entry and displaying various options. 
  However, I'm unable as long holding is not doing/invoking anything.</p>
  
  <p><strong>This the code that I'm using to invoke the context menu:</strong></p>
  
  <pre><code>@Override
  public void onCreateContextMenu(ContextMenu menu, View v,
          ContextMenuInfo menuInfo) {
      super.onCreateContextMenu(menu, v, menuInfo);
  
      MenuItem delete = menu.add("delete");
      MenuItem edit = menu.add("edit");
      delete.setOnMenuItemClickListener(new OnMenuItemClickListener() {
          public boolean onMenuItemClick(MenuItem item) {
              return true;
          }
      });
      edit.setOnMenuItemClickListener(new OnMenuItemClickListener() {
          public boolean onMenuItemClick(MenuItem item) {
              return true;
          }
      });
  }
  </code></pre>
  
  <p><strong>I have also tried, but to no avail either:</strong></p>
  
  <pre><code>@Override
  public void onCreateContextMenu(ContextMenu menu, 
                  View v, ContextMenuInfo menuInfo) {
      menu.add(0, 1, 0, "Edit");
      menu.add(0, 2, 1, "Rename");
      menu.add(0, 3, 2, "Delete");
      super.onCreateContextMenu(menu, v, menuInfo);
  }
  
  @Override
  public boolean onContextItemSelected(MenuItem item) {
      super.onContextItemSelected(item);
  
      if(item.getTitle().equals("Edit")) {
          //Edit code
      } else if(item.getTitle().equals("Rename")) {
          //Rename code
      } else if(item.getTitle().equals("Delete")) {
          //Delete code
      }
      return true;
  };
  </code></pre>
  
  <p><strong>MainActivity code (only relevant parts):</strong></p>
  
  <pre><code>public class MainActivity extends Activity {
      private List&lt;CountElement&gt; myElements = new ArrayList&lt;CountElement&gt;();
      ListView list;
      ArrayAdapter&lt;CountElement&gt; adapter;
  
      /*
      Users enters needed listview items, code not shown here. It works fine however - 
      all needed elements are displayed correctly.
      */
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
  
          adapter = new MyListAdapter();
          list = (ListView) findViewById(R.id.listView1);
          list.setAdapter(adapter);
          registerForContextMenu(list);
      }
  
      @Override
      public void onCreateContextMenu(ContextMenu menu, View v,
              ContextMenuInfo menuInfo) {
          super.onCreateContextMenu(menu, v, menuInfo);
  
          MenuItem delete = menu.add("delete");
          MenuItem edit = menu.add("edit");
          delete.setOnMenuItemClickListener(new OnMenuItemClickListener() {
              public boolean onMenuItemClick(MenuItem item) {
                  return true;
              }
          });
          edit.setOnMenuItemClickListener(new OnMenuItemClickListener() {
              public boolean onMenuItemClick(MenuItem item) {
                  return true;
              }
          });
      }
  
      private class MyListAdapter extends ArrayAdapter&lt;CountElement&gt; {
          //Custom adapter code here
      }
  }
  </code></pre>
  
  <p>Any help is greatly appreciated. Thank you!</p>