画面の上にactionBar tabのViewPagerページにカバーtabを埋め込んで画面の下に表示します


在屏幕上方是actionBar tab的ViewPager页面里面嵌套子tab并显示于屏幕下方
参考になりましたhttp://simplehappy.iteye.com/blog/1783845、android-support-v 13の中のFragmentTabHostで実現して、コードの断片:
public class TabHostFragment extends Fragment {

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        View v = inflater.inflate(R.layout.main_linear, container, false);
        
        FragmentTabHost fragmentTabHost = (FragmentTabHost) v.findViewById(R.id.fragmentTabHosts);
        fragmentTabHost.setup(getActivity(), getChildFragmentManager(), R.id.tabContent);
        
        fragmentTabHost.addTab(fragmentTabHost.newTabSpec("Simple").setIndicator("Simple"),
                CountingFragment.class, null);
        fragmentTabHost.addTab(fragmentTabHost.newTabSpec("List").setIndicator("List"),
                FragmentPagerSupport.ArrayListFragment.class, null);
        fragmentTabHost.addTab(fragmentTabHost.newTabSpec("Cursor").setIndicator("Cursor"),
                CursorFragment.class, null);
        
        return v;
    }

}
main_linear.xml、androidを宣言する必要があります.support.v13.app.FragmentTabHostのコントロール:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >

    <FrameLayout
        android:id="@+id/tabContent"
        android:layout_width="match_parent"
        android:layout_height="0dip"
        android:layout_weight="1" />

    <android.support.v13.app.FragmentTabHost
        android:id="@+id/fragmentTabHosts"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" />

</LinearLayout>
中FragmentTabHost.setup(Context context,FragmentManager manager,int containerId)のcontainerIdに対応するviewは表示するtabの内容で、android:layout_weight=「1」方式でtabHostを下に押し込む(垂直レイアウトではtabHostの上にある)これによりtabタブが下に表示される効果が得られる.第1層tab用ActionBarはfirefoxの閲覧tabタグに似た効果があることが推奨されるが、従来のtab実装では、複数のtabタグが画面幅を平均的に分けており、tab数が多い場合には非常に混雑している.ActionBarで実現されたtabは、多く出たtabは表示されない.徐々にドラッグして表示するとともに、表示されたtabが見えない領域に移動します.
上のコードのsetup(getActivity(), getChildFragmentManager(), R.id.tabContent)の2番目のパラメータはchildFragmentManagerでなければなりませんが、問題が発生しました.4.2プラットフォームの前にandroid.app.FragmentにはgetChildFragmentManager()メソッドはありません.(以前は4.2のプラットフォームでコンパイルして4.0のシミュレータで実行していましたが、NoSuchMethodErrorが現れて4.2のシミュレータで実行すればいいです).
4.2以前の携帯電話で上記のように実現するにはandroidを使う.support.v4.app.Fragment、このクラスにはgetChildFragmentManager()メソッドがあります.このメソッドの戻りタイプはandroidです.support.v4.app.Fragmentは、一連の変更を招き、使用するFragmentTabHostはv 13ではなく、v 4であり、表示ページのActivityも含めてandroidしか使用できない.support.v4.app.FragmentActivity、FragmentPagerAdapterもv 4にします.詳細はコードを参照してください.http://download.csdn.net/download/tedzyc/5050980(V 4.2のバージョンはNew Android Projects from existing codeでインポート).