开发者

registerForContexMenu on two different lists

开发者 https://www.devze.com 2023-03-18 03:54 出处:网络
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

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);
0

精彩评论

暂无评论...
验证码 换一张
取 消