我有一个操作栏活动。当我从一个片段切换到另一个片段时,片段有两个菜单,如设置,gridview。当我单击设置时,它执行操作但不在gridview中。在每个片段的第一个菜单项中只执行不在第二个片段中的动作。请给我解决方案谢谢.....
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
super.onCreateOptionsMenu(menu, inflater);
menu.clear();
getActivity().getMenuInflater().inflate(R.menu.settingmenu, menu);
getActivity().getMenuInflater().inflate(R.menu.menugridcalendar, menu);
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.menu_setting:
Log.i(TAG,"InsdieGridmenu");
Intent intent = new Intent(getActivity(), SettingPage.class);
startActivity(intent);
break;
case R.id.gridmenuid:
Activity activity = getActivity();
if (activity instanceof ListItemClickListener) {
((ListItemClickListener)activity).OpenGridView();
}
break;
}
return true;
}