2012-03-31 7 views
1

XML layout(「内部」レイアウトと呼ばれます)、内部レイアウトを別のカスタムXMLレイアウト(「外部」レイアウトと呼ぶ)からどのように参照しますか?これは、XMLだけを使用して可能ですか、またはプログラムによる唯一のソリューションですか?別のカスタムXMLレイアウトからカスタムXMLレイアウトをどのように参照しますか?

インナーレイアウト:

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:padding="6dip" 
    > 
    <ImageView 
    android:id="@+id/productImage" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_alignParentRight="true" 
    android:layout_marginLeft="6dip" 
    /> 
    <TextView 
    android:id="@+id/productName" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:layout_toLeftOf="@id/productImage" 
    android:textAppearance="?android:attr/textAppearanceLarge" 
    /> 
</RelativeLayout> 

外レイアウト:

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    > 
    <!-- Embed inner XML layout here --> 
    <Button 
    android:id="@+id/productButtonAddToShoppingList" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_below="<!-- refer to inner layout -->" 
    android:layout_marginTop="2dip" 
    android:text="add to shopping list" 
    /> 
</RelativeLayout> 

答えて

関連する問題