也許閱讀this文章。
下面是一個佈局xml文件的示例,它具有兩個彼此相鄰的片段,寬度均勻。
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
>
<fragment
class="package.of.fragmentA"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="match_parent"
android:id="@+id/fragmentA"
/>
<fragment
class="package.of.fragmentB"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="match_parent"
android:id="@+id/fragmentB"
/>
</LinearLayout>
在Gmail應用程序的類fragmentA將是一個ListFragment和fragmentB將是一個正常的片段類與自定義佈局文件的情況下。
你應該看看自定義適配器。你想要做的是使用自定義適配器而不是標準即插即用適配器進行列表視圖。 – Warpzit 2012-07-30 13:04:53
我們已經使用自定義適配器和ListFragment來代替單個Activity或Fragment,但即使我們使用了setListAdapter(myAdapter),我們也無法在片段中看到我們的佈局。 – nhr 2012-07-30 13:35:03