Fragment的布居文件中 创建了一个FragmentTabHost 初始化时
public View onCreateView(LayoutInflater inflater, ViewGroup container,Bundle savedInstanceState) {
View view= inflater.inflate(R.layout.fragment_2, null);
mTabHost=(FragmentTabHost)view.findViewById(android.R.id.tabhost);
// 需要要用getChildFragmentManager() 来获得 FragmentManager对象
mTabHost.setup(getActivity(),getChildFragmentManager(), R.id.realtabcontent2);
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
>
<android.support.v4.app.FragmentTabHost
android:id="@android:id/tabhost"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
</android.support.v4.app.FragmentTabHost>
<FrameLayout
android:id="@+id/realtabcontent2"
android:layout_width="match_parent"
android:layout_height="0dip"
android:layout_weight="1" />