How can I create a Fragment with tabs on the top, hosting other Fragments?
I previously used android.support.v4.app.Fragment
but switched to android.app.Fragment
because of the PreferenceFragment
class. My code was:
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_tabs,container, false);
mTabHost = (FragmentTabHost)rootView.findViewById(android.R.id.tabhost);
mTabHost.setup(getActivity(), getChildFragmentManager(), R.id.realtabcontent);
mTabHost.addTab(mTabHost.newTabSpec("fragmentb").setIndicator("Fragment B"),
FragmentB.class, null);
return rootView;
}
But this don't work anymore because setup
require a v4-FragmentManager.
Any suggestion how to solve this problem?
Thanks in advance!