ここでの問題は、含まれているビューの ID を渡して Fragment.onCreateView を呼び出したことです。この包含ビューはビュー自体であるため、当然のことながら、コードは私のコードを包含ビューであると考えていたもの、つまりそれ自体にアタッチしようとしました。したがって、無限再帰。別の問題は、inflation コードが activity_shop2_drop.xml で「fragment」タグを検出すると ClassNotFoundException を返し、その結果フラグメントで「onCreateView」を呼び出さないことです。私はまだこれを解決していません。activity_shop2_drop.xml コードは次のとおりです。
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/whole_app_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<fragment
class="com.victorpreston.shop2drop.S2DButtonFragment"
android:id="@+id/buttonFragmetLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<fragment
class="com.victorpreston.shop2drop.S2DListFragment"
android:id="@+id/listFragment"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
ここに、button_fragment_layout.xml コードを示します。
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/buttonFragmentLayout"
android:layout_width="match_parent"
android:layout_height="40dip"
android:orientation="horizontal">
<Button
android:id="@+id/newItemButton"
android:layout_width="0dip"
android:layout_height="40dip"
android:layout_weight="1"
android:text="@string/newColumnButton" />
<Button
android:id="@+id/newColumnButton"
android:layout_width="0dip"
android:layout_height="40dip"
android:layout_weight="1"
android:text="@string/newItemButton" />
<Button
android:id="@+id/exitButton"
android:layout_width="0dip"
android:layout_height="40dip"
android:layout_weight="1"
android:text="@string/exitButton" />
</LinearLayout>
どちらも同じ ID を作成して使用することに注意してください。私はそれを変更しようとしましたが、違いはなかったので、それは問題ではないと思います.