Eclipse プロジェクト ウィザードを使用して、ActionBar とタブを含むプロジェクトを作成しました。ウィザードは、タブ番号のみを示すダミー テキストを含む各タブのダミー フラグメントを作成します。アプリは問題なく動作します。
コードは次のようになります。
   @Override
    public void onTabSelected(ActionBar.Tab tab, FragmentTransaction fragmentTransaction) {
        // When the given tab is selected, show the tab contents in the container
        Fragment fragment = new DummySectionFragment();
        Bundle args = new Bundle();
        args.putInt(DummySectionFragment.ARG_SECTION_NUMBER, tab.getPosition() + 1);
        fragment.setArguments(args);
        getFragmentManager().beginTransaction()
                .replace(R.id.container, fragment)
                .commit();
    }
   /** 
     * A dummy fragment representing a section of the app, but that simply displays dummy text.
     */
    public static class DummySectionFragment extends Fragment {
        public DummySectionFragment() {
        }
        public static final String ARG_SECTION_NUMBER = "section_number";
        @Override
        public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
            TextView textView = new TextView(getActivity());
            textView.setGravity(Gravity.CENTER);
            Bundle args = getArguments();
            textView.setText(Integer.toString(args.getInt(ARG_SECTION_NUMBER)));
            return textView;
        }
    }
私のアプリの目的のために、デバイスが縦向きモードのときは 1 つのフラグメントを表示し、デバイスが横向きモードのときは 2 つのフラグメントを表示したいと思います。Shakespeare サンプルについては知っていますが、このサンプルでは、1 つまたは 2 つのフラグメントを保持するアクティビティです。
シェイクスピアのサンプルでは、2 つの異なるレイアウトが使用されています。縦向きモードの場合 (「layout\fragment_layout_support.xml」内):
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent" android:layout_height="match_parent">
    <fragment class=".FragmentLayoutSupport$TitlesFragment"
            android:id="@+id/titles"
            android:layout_width="match_parent" android:layout_height="match_parent" />
</FrameLayout>
横向きモードの場合 (「layout-land\fragment_layout_support.xml」内):
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="horizontal"
    android:layout_width="match_parent" android:layout_height="match_parent">
    <fragment class=".FragmentLayoutSupport$TitlesFragment"
            android:id="@+id/titles" android:layout_weight="1"
            android:layout_width="0px" android:layout_height="match_parent" />
    <FrameLayout android:id="@+id/details" android:layout_weight="1"
            android:layout_width="0px" android:layout_height="match_parent" />
</LinearLayout>
Shakespeare サンプルは、次のようにレイアウトを読み込みます。
public class FragmentLayoutSupport extends FragmentActivity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        //setTheme(SampleList.THEME); //Used for theme switching in samples
        super.onCreate(savedInstanceState);
        setContentView(R.layout.fragment_layout_support);
    }
...
FragmentActivity でレイアウトを読み込めないアプリで同じことを行うにはどうすればよいですか?
ありがとう。