Android 两个列表中的onCreateContextMenu
我使用的是一个sherlock库,我有一个SherlockBar+ViewPagerIndicator和2个SherlockListFragment,我需要在每个列表中使用Android 两个列表中的onCreateContextMenu,android,actionbarsherlock,fragment,Android,Actionbarsherlock,Fragment,我使用的是一个sherlock库,我有一个SherlockBar+ViewPagerIndicator和2个SherlockListFragment,我需要在每个列表中使用onCreateContextMenu,我在main中编写了一个oveeride方法扩展SherlockFragmentActivity @Override public void onCreateContextMenu(ContextMenu contextMenu, View view, ContextMenu.Conte
onCreateContextMenu
,我在main中编写了一个oveeride方法扩展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);
}
,但上下文菜单仅在第一个列表中起作用。我的错在哪里
谢谢 您应该确保在为每个片段创建的ActivityCreated中调用registerForContextMenu
public void onActivityCreated(Bundle savedState) {
registerForContextMenu(getListView());
}
问题是上下文菜单只为第一个片段注册,我尝试在每个片段中创建onCreateContextMenu。但这没有帮助