I have an Intent that extends a ListActivity. In my onCreate method after having populated the list adapter I use registerForContextMenu(getListView());>
Here is another simpler way to show context menu on single click.
private void addOnClickListener()
{
contactList.setOnItemClickListener(new AdapterView.OnItemClickListener()
{
public void onItemClick(AdapterView> parent, View view, int position, long id)
{
view.showContextMenu();
}
})
}
replace contactList by your ListView and make sure to call this method after the initialization of ListView.