android - onCreateContextMenu in two lists -


i'm using sherlock lib , have sherlockbar + viewpagerindicator 2 sherlocklistfragment, need use oncreatecontextmenu in each list, wrote oveeride method in main extends sherlockfragmentactivity

@override public void oncreatecontextmenu(contextmenu contextmenu, view view, contextmenu.contextmenuinfo contextmenuinfo) {     if(indicator.getcurrentitem()==page_m) {         getmenuinflater().inflate(r.menu.mcontextmenu, contextmenu);         messageviewholder=(messageviewholder )view.gettag();     }     else {         getmenuinflater().inflate(r.menu.ccontextmenu, contextmenu);         messageviewholder=null;     }     super.oncreatecontextmenu(contextmenu, view, contextmenuinfo); } 

, context menu works in first list. mistake?

thanks!

you should make sure call registerforcontextmenu inside onactivitycreated each fragment .

public void onactivitycreated(bundle savedstate) { registerforcontextmenu(getlistview()); } 

Comments