I want to open the aboutActivity upon selecting the contextmenu item but nothing happens when I select any item from the contextmenu.
Here is the code:
public boolean onContextItemSelected(MenuItem menu){
// get menu id
int menuid = menu.getItemId();
switch (menuid){
case 0:
Intent intnt2 = new Intent(ListActivity.this,aboutActivity.class);
startActivity(intnt2);
break;
case 1:
Intent intnt3 = new Intent(ListActivity.this,aboutActivity.class);
startActivity(intnt3);
break;
}
return super.onContextItemSelected(menu);
}
I have declared the aboutActivity in manifest file and I have another menu item(named "About") which lauches the aboutActivity.Any help?
[Edit] This is the onCreateContextMenu function:
public void onCreateContextMenu(ContextMenu menu,View view,ContextMenuInfo menuInfo){
//checking if the long press is coming from ListView or not
if(view.getId()==R.id.mainlist){
//AdapterView.AdapterContextMenuInfo ainfo= (AdapterContextMenuInfo) menuInfo;
menu.setHeaderTitle("Item menu");
menu.add(Menu.NONE,0,0,"Edit");
menu.add(Menu.NONE,1,0,"Delete");
}
}
How to use R.id here,as raghunandan suggested?