I have the following structure of my app:
v4 FragmentActivity --> v4 ViewPager --> v4 Fragment
--> v4 ListFragment
I'm using ActionBarSherlock (which I would really recommend), and the structure of the Activity is based on the demo at https://github.com/JakeWharton/ActionBarSherlock/blob/master/samples/demos/src/com/actionbarsherlock/sample/demos/app/ActionBarTabsPager.java . So the two fragments are displayed as two tabs for the user.
When a user clicks an element of the ListFragment I want to load an url in a WebView in the same place as the list is. That is, I want to replace the ListFragment (put it on the back stack) with a new WebView.
So far I've tried using FragmentTransaction.replace() from the Activity. That kind of works, except two issues:
- The ListFragment doesn't display the WebView before I rotate the device (i.e. the acitity is recreated).
- The content of the other tab disappears (it's just blank)
What is the correct way to replace the ListFragment with another Fragment?