У меня есть макет, как показано ниже. Он содержит несколько TextView и ImageView. Ниже я хотел бы добавить ListFragment.Как добавить встроенный 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>
Сейчас я добавляю свой список, используя код ниже. Но я хотел бы добавить его, как показано выше. Я предполагаю, что я добавлю его таким же образом, но какой элемент я должен использовать в своем макете в качестве контейнера?
FragmentManager fm = getSupportFragmentManager();
if (fm.findFragmentById(android.R.id.content) == null) {
ProgramListFragment list = new ProgramListFragment();
fm.beginTransaction().add(android.R.id.content, list).commit();
}
Любые предложения по его добавлению в линию?
так просто поставить listfragment в вашем XML, а не в коде – tyczj
я запутался о том, как сделать это. И в некоторых случаях я хочу передать параграф в ProgramListFragment. Не могли бы вы просветить меня? – user672009