0
我有這個main.xml佈局,它有一個固定的頁眉和頁腳。正文內容必須根據收到的參數進行更改。充氣視圖android
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="fill_parent" android:background="#FFFFFF"
android:id="@+id/main_view">
<com.HeaderView
android:id="@+id/HeaderView"
android:layout_alignParentTop="true"
android:layout_width="fill_parent" android:layout_height="wrap_content" />
<com.FooterView
android:id="@+id/FooterView"
android:layout_alignParentBottom="true" android:layout_width="match_parent"
android:layout_height="wrap_content" />
<RelativeLayout android:layout_width="fill_parent"
android:layout_height="wrap_content" android:id="@+id/BodyView"
android:layout_below="@id/HeaderView"
android:layout_above="@id/FooterView"/>
</RelativeLayout>
根據以下條件我需要在main.xml中加載BodyView。
If parameter == Apple
then load layout AppleView in the BodyView
if parameter == Bat
then load layout BatView in the BodyView
我已經定義了AppleView和BatView xml佈局。有人請指導我如何加載任何視圖,並設置/從中獲取值。
我很抱歉,但我仍然無法弄清楚如何使用這段代碼。請您詳細說明 –
每次測試後(每次後)你這樣做(做膨脹的佈局。 –