Android-動態地將視圖添加到視圖中我有個景觀布局-<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="0px"
android:orientation="vertical">
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/items_header"
style="@style/Home.ListHeader" />
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/items_none"
android:visibility="gone"
style="@style/TextBlock"
android:paddingLeft="6px" />
<ListView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/items_list" /></LinearLayout>我想做的是,在我的主要活動中做這樣的布局<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="0px"
android:id="@+id/item_wrapper"></LinearLayout>我想循環遍歷我的數據模型,并將包含第一個布局的多個視圖注入主布局中。我知道我可以通過在代碼中完全構建控件來實現這一點,但是我想知道是否有一種方法可以動態地構建視圖,這樣我就可以繼續使用布局,而不是把所有的東西都放在代碼中。
- 3 回答
- 0 關注
- 551 瀏覽
添加回答
舉報
0/150
提交
取消