I have implemented a project with 1 activity, actionBar with tab Navigation mode (5 tabs, each one is a fragment).
Each fragment have its own menu options (in action bar).
What I need is that when user clicks one of that options, change the layout of that current fragment. I know where to put the code, in this case it will be something like this...
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
inflater.inflate(R.menu.fragment1, menu);
super.onCreateOptionsMenu(menu, inflater);
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.menu_listMode:
//Here I need to put the code to change layou of this current fragment...
return true;
default:
break;
}
return true;
}
To be more specific... An example would be: You have a fragment with a calendar view, and when you click the option in the action bar, that view changes to a listViewFragment. (The layout changes, but the tab it's the same).
I have used this sample project: https://github.com/sgolivernet/curso-android-src/tree/master/android-actionbar-tabs