私は次のようなレイアウトを持っています。いくつかの TextView と ImageView が含まれています。それらの下に、ListFragment を追加したいと思います。
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Name: "
android:id="@+id/textView"
android:layout_gravity="left|center_vertical" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:id="@+id/name"
android:layout_toRightOf="@+id/textView"
android:layout_gravity="left"
android:text="Large Text" />
...
<fragment android:id="@+id/list"
android:layout_below="@id/name"
class="com.snot.bodyweightworkout.ExerciseListFragment"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</RelativeLayout>
現在、以下のコードを使用して ListFragment を追加しています。しかし、上記のように追加したいと思います。同じ方法で追加すると思いますが、レイアウトでどの要素をコンテナとして使用すればよいですか?
FragmentManager fm = getSupportFragmentManager();
if (fm.findFragmentById(android.R.id.content) == null) {
ProgramListFragment list = new ProgramListFragment();
fm.beginTransaction().add(android.R.id.content, list).commit();
}
インラインで追加する方法について何か提案はありますか?