I hava 2 listvies on the same activity list1 and list2开发者_如何学C. I want to have A,B,C items when press and hold on list1, and P,O,I on list2
how can this be done ? Should I call registerforcontextmenu(list1); and registerforcontextmenu(list2); ?? and what afterwards . . .
Thanks
you want different contextMenu for different Listview then try this
then create context Menu
@Override
public void onCreateContextMenu(ContextMenu menu, View v,
ContextMenuInfo menuInfo) {
super.onCreateContextMenu(menu, v, menuInfo);
if(v==list1)
{
menu.add(Menu.NONE, 0, Menu.NONE, "A");
menu.add(Menu.NONE, 1, Menu.NONE, "B");
menu.add(Menu.NONE, 2, Menu.NONE, "C");
}
else if(v==list2)
{
menu.add(Menu.NONE, 3, Menu.NONE, "P");
menu.add(Menu.NONE, 4, Menu.NONE, "Q");
menu.add(Menu.NONE, 5, Menu.NONE, "R");
}
}
and register conextMenu on both listview.
registerForContextMenu(list1);
registerForContextMenu(list2);
精彩评论