display context menu for position "2" click in list view only android
<p>I want to display context menu for list position clicked means only for 2 nd position clicked in list view so how to do it.</p>

<p>I had implemented the code for displaying context menu for each position clicked. So how to make it specific for any position in <code>ListView</code>.</p>

<p>my code for displaying context menu for each position in list view ..pls do required modification  on my code thanks...</p>

<pre><code>public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.mainmenulist);

    // registerForContextMenu(getListView());

    CustomAdapter adapter = new CustomAdapter(
        this, R.layout.listitem,R.id.title, data
    );
    setListAdapter(adapter);

    getListView().setTextFilterEnabled(true);
}

@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, "Gallery");
    menu.add(0, v.getId(), 0, "Camera");
    menu.add(0, v.getId(), 0, "Cancel");
}

@Override
public boolean onContextItemSelected(MenuItem item) {
    if(item.getTitle()=="Gallery"){
        function1(item.getItemId());
    } else if(item.getTitle()=="Camera"){
        function2(item.getItemId());
    } else return false;
    return true;
}

public void function1(int id){
    Toast.makeText(this, "Gallery function called",
      Toast.LENGTH_SHORT)
    .show();
}

public void function2(int id){
    Toast.makeText(this, "Camera function  called",
      Toast.LENGTH_SHORT)
    .show();
}
</code></pre>
