I'm trying to use tabs on android 2.2 - 4.0. I've extended this demo: http://developer.android.com/resources/samples/Support4Demos/src/com/example/android/supportv4/app/FragmentTabs.html with:
TabSpec ts = mTabHost.newTabSpec("randomTab");
Intent intent = new Intent();
intent.setClass(this, FragActiv.class);
ts.setContent(intent);
ts.setIndicator("randomTab");
mTabManager.addTab(ts, FragActiv.class, new Bundle());
But I don't know what to add to onTabChanged, where all the magic happens in the demo.
What I need to do is:
I have a ListFragment
and when an item is clicked, it should display details in a separate screen on a small screen/portrait orientation or, on a large screen/landscape orientation, display a fragment with the details on the same screen. Can I work around this with Fragments or should I try to get FragmentActivities
working properly?
By following this example: example, I was able to instantiate a FragmentActivity, but it takes up the whole screen, rather than just the area under the tab menu.
Is there any chance of using Activities (or FragmentActivities), not Fragments, as contents of the tabs?
There was no need of doing what I wanted (using a TabActivity as content of a tab). I've solved the problem by having two containers inside my tabContent, one for the ListView fragment and one for the details fragment. Here is my layout now:
Initially, details_container is GONE. You can use it as following: