0
我正在嘗試解剖和使用android碎片的這個例子。請原諒我張貼鏈接,但代碼本身有點多,我不確定我應該在這裏發佈。使用android碎片數組
佈局是相當直接:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="match_parent" android:layout_height="match_parent">
<fragment class="conti.fragments.FragmentLayout$TitlesFragment"
android:id="@+id/titles" android:layout_weight="1"
android:layout_width="0px" android:layout_height="match_parent" />
<FrameLayout android:id="@+id/details" android:layout_weight="1"
android:layout_width="0px" android:layout_height="match_parent"
android:background="?android:attr/detailsElementBackground" />
</LinearLayout>
至於我能理解,顯示在基本上是從第一陣列中的所有字符串列表左邊,當你按下它時,它會在右邊顯示相應的訂單文本。我如何添加一個菜單項來完成與顯示右側相應文本不同的菜單項?如果我想爲這個新片段定義自己的佈局,是否需要修改佈局文件或創建一個新的佈局文件?或者我必須在代碼中以編程方式創建它?我有點困惑。
誇大自己的佈局你可以改變你的公共靜態類DetailsFragment擴展片段。在公共視圖onCreateView(LayoutInflater inflater,ViewGroup容器, Bundle savedInstanceState){充氣自己的佈局 – eurosecom