title: Implement OnClickListener to make Show Context Menu With Short Click not Long Click
body: <p>I have code like this :</p>
  
  <pre><code>public class ListConActivity extends Activity {
  
      private String[] Distro = { "Ubuntu", "Arch Linux", "Mandriva",
              "Open Suse", "IGOS Nusantara", "Linux Mint", "Debian", "Fedora",
              "CrunchBang", "Backtrack", "Puppy Linux", "OpenBSD", "Slackware",
              "BlankOn", "CentOS" };
      private String[] pilihan_menu = { "Tambah Data", "Edit Data", "Hapus Data",
              "Kirim Data" };
  
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.main);
          Arrays.sort(Distro);
  
          ListView list = (ListView) findViewById(R.id.list);
          ArrayAdapter&lt;String&gt; adapter = new ArrayAdapter&lt;String&gt;(this,android.R.layout.simple_list_item_1, Distro);
          list.setAdapter(adapter);
          registerForContextMenu(list);
      }
  
      public void onCreateContextMenu(ContextMenu menu, View tampil,
              ContextMenuInfo menuInfo) {
          if (tampil.getId() == R.id.list) {
              AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) menuInfo;
              menu.setHeaderTitle(Distro[info.position]);
              for (int i = 0; i &lt; pilihan_menu.length; i++) {
                  menu.add(Menu.NONE, i, i, pilihan_menu[i]);
              }
          }
      }
  
      public boolean onContextItemSelected(MenuItem item) {
          AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) item
                  .getMenuInfo();
          String aksi = pilihan_menu[item.getItemId()];
          String nama_pilihan = Distro[info.position];
          String isi = String.format("Anda melakukan operasi %s pada pilihan %s",
                  aksi, nama_pilihan);
  
          Toast.makeText(this, isi, Toast.LENGTH_LONG).show();
          return true;
      }
  }
  </code></pre>
  
  <p>Its work perfectly showing contextmenu for long click. I changed the code to implement the onclick to be able to open a context menu with a short click.</p>
  
  <pre><code>public class ListConActivity extends Activity implements OnClickListener {
  
      private String[] Distro = { "Ubuntu", "Arch Linux", "Mandriva",
              "Open Suse", "IGOS Nusantara", "Linux Mint", "Debian", "Fedora",
              "CrunchBang", "Backtrack", "Puppy Linux", "OpenBSD", "Slackware",
              "BlankOn", "CentOS" };
      private String[] pilihan_menu = { "Tambah Data", "Edit Data", "Hapus Data",
              "Kirim Data" };
  
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.main);
          Arrays.sort(Distro);
  
          ListView list = (ListView) findViewById(R.id.list);
          ArrayAdapter&lt;String&gt; adapter = new ArrayAdapter&lt;String&gt;(this,android.R.layout.simple_list_item_1, Distro);
          list.setAdapter(adapter);
          registerForContextMenu(list);
          list.setOnClickListener(this);
  
      }
  
      public void onCreateContextMenu(ContextMenu menu, View tampil,
              ContextMenuInfo menuInfo) {
          if (tampil.getId() == R.id.list) {
              AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) menuInfo;
              menu.setHeaderTitle(Distro[info.position]);
              for (int i = 0; i &lt; pilihan_menu.length; i++) {
                  menu.add(Menu.NONE, i, i, pilihan_menu[i]);
              }
          }
      }
  
      public boolean onContextItemSelected(MenuItem item) {
          AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) item
                  .getMenuInfo();
          String aksi = pilihan_menu[item.getItemId()];
          String nama_pilihan = Distro[info.position];
          String isi = String.format("Anda melakukan operasi %s pada pilihan %s",
                  aksi, nama_pilihan);
  
          Toast.makeText(this, isi, Toast.LENGTH_LONG).show();
          return true;
      }
  
      @Override
      public void onClick(View v) {
          // TODO Auto-generated method stub
          openContextMenu(v);
      }
  }
  </code></pre>
  
  <p>Compile success.. But i get force close. Can u help me? thanks dude!</p>