私のアプリには、2つのボタンと、ListFragmentが読み込まれるスペースがあります。ボタンがレイアウトの一番上にあるように定義されている場合、アプリは希望どおりに実行されます。
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_weight="1"
android:layout_height="0px"
android:orientation="horizontal" >
<Button
android:id="@+id/displayfragment1"
android:layout_height="match_parent"
android:layout_width="wrap_content"
android:text="@string/button_fragment1" />
<Button
android:id="@+id/displayfragment2"
android:layout_height="match_parent"
android:layout_width="wrap_content"
android:text="@string/button_fragment2" />
</LinearLayout>
<LinearLayout
android:id="@+id/myfragment"
android:layout_width="match_parent"
android:layout_weight="5"
android:layout_height="0px" />
</LinearLayout>
ただし、以下のようにフラグメントレイアウトをボタンの上に移動すると、起動時にアプリがクラッシュします。
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<LinearLayout
android:id="@+id/myfragment"
android:layout_width="match_parent"
android:layout_weight="5"
android:layout_height="0px" />
<LinearLayout
android:layout_width="match_parent"
android:layout_weight="1"
android:layout_height="0px"
android:orientation="horizontal" >
<Button
android:id="@+id/displayfragment1"
android:layout_height="match_parent"
android:layout_width="wrap_content"
android:text="@string/button_fragment1" />
<Button
android:id="@+id/displayfragment2"
android:layout_height="match_parent"
android:layout_width="wrap_content"
android:text="@string/button_fragment2" />
</LinearLayout>
</LinearLayout>
これは私がこのクラッシュを引き起こすために行っている唯一の変更であり、これが問題であるに違いないと思いますか?