My question looks similar to this. However, it is a bit more in general: Let me try to explain: I am using the ActionBarSherlock with the Tabsadapter and Viewpager. I have replaced all the fragments with my own and now I have a button in one of my fragments which, when clicked on, starts the following onclick handler:
public void onAcceptSelected() {
SherlockFragment addFirstChildFragment = AddChildFragment.newInstance();
getSupportActionBar().setTitle("The new title of the fragment here");
FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
ft.replace(R.id.pager, addFirstChildFragment);
ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN);
ft.addToBackStack(null);
ft.commit();
}
The problem is then that the following method in the new fragment:
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View v = inflater.inflate(R.layout.fragment_childeditor, container, false);
return v;
}
does not result in actually providing a new visible layout: the tab its contents are empty (e.g. I see a holo white themed empty tab).
Now I have the following questions:
My main question is: "How should I replace fragments within a tab?" with subquestions:
The answer resides in the answers to this question Actionbarsherlock + tabs + multi fragments?
Answers to my questions are: 1. No this is not necessary: I can add them programaticllay. 2. I can use fragmentstacks as the example shows in the link above.