Eine Ansicht / ein Layout in ein anderes Layout aufblasen?
Ich bin auf der Suche nach einem Weg, aufblasen, um ein anderes layout in das erste layout in android. Wie würde man dies tun? Hier sind die beiden XML-Dateien. Die erste ist die Haupt-layout, die zweite ist das layout würde ich gerne aufblasen, in die erste.
Kann ich nicht nur das layout, wie werde ich diese Methode verwenden, aufblasen, um andere layouts in wire frames später.
Code auch bei: http://pastebin.com/wjZ4s1cs wie stackoverflow nicht wie bei XML.
<?xml version="1.0" encoding="utf-8"?>
<AbsoluteLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#ff000000"
>
<TextView
android:id="@+id/headerMenuText"
android:text="@string/main_menu_title"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:textSize="16pt"
android:paddingTop="10px"
android:paddingBottom="10px"
android:gravity="center"
>
</TextView>
<TableLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_y="100dip"
android:gravity="center"
android:layout_gravity="center"
>
<TableRow
android:gravity="center"
android:layout_gravity="center">
<ImageView
android:id="@+id/menuItem1"
android:layout_height="101dip"
android:layout_width="89dip"
android:src="@drawable/icon_settings"
></ImageView>
<ImageView
android:id="@+id/menuItem2"
android:layout_height="101dip"
android:layout_width="89dip"
android:src="@drawable/icon_system_restart"
></ImageView>
<ImageView
android:id="@+id/menuItem3"
android:layout_height="101dip"
android:layout_width="89dip"
android:src="@drawable/icon_game_history"
></ImageView>
<ImageView
android:id="@+id/menuItem4"
android:layout_height="101dip"
android:layout_width="89dip"
android:src="@drawable/icon_game_correction"
></ImageView>
<ImageView
android:id="@+id/menuItem5"
android:layout_height="101dip"
android:layout_width="89dip"
android:src="@drawable/icon_game_other"
></ImageView>
</TableRow>
<TableRow android:gravity="center">
<TextView
android:id="@+id/menuItemText1"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="@string/main_menu_item_text_1"
android:layout_gravity="center"
android:gravity="center"
></TextView>
<TextView
android:id="@+id/menuItemText2"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="@string/main_menu_item_text_2"
android:layout_gravity="center"
android:gravity="center"
></TextView>
<TextView
android:id="@+id/menuItemText3"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="@string/main_menu_item_text_3"
android:layout_gravity="center"
android:gravity="center"
></TextView>
<TextView
android:id="@+id/menuItemText4"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="@string/main_menu_item_text_4"
android:layout_gravity="center"
android:gravity="center"
></TextView>
<TextView
android:id="@+id/menuItemText5"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="@string/main_menu_item_text_5"
android:layout_gravity="center"
android:gravity="center"
></TextView>
</TableRow>
</TableLayout>
<View or layout
android:id="@+id/screen_layout_bottom_menu"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
>
</View or layout>
</AbsoluteLayout>
Zweite layout
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/screen_bottom_menu"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
>
<TableLayout
android:id="@+id/screen_bottom_menu_table"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
>
<TableRow>
<ImageView
android:id="@+id/screen_bottom_menu_button_back"
android:src="@drawable/back">
</ImageView>
<ImageView
android:id="@+id/screen_bottom_menu_button_ok"
android:src="@drawable/checkmark">
</ImageView>
<ImageView
android:id="@+id/screen_bottom_menu_button_cancel"
android:src="@drawable/xmark">
</ImageView>
<ImageView
android:id="@+id/screen_bottom_menu_button_key_toggle"
android:src="@drawable/lock">
</ImageView>
</TableRow>
</TableLayout>
</LinearLayout>
InformationsquelleAutor der Frage Kevin Parker | 2011-03-17
Du musst angemeldet sein, um einen Kommentar abzugeben.
Es ist
ViewStub
aber ich habe es nie benutzt und ich glaube, es kann nicht mehr als einmal verwendet werden.Können Sie Pumpen Sie den Menü-layout und befestigen Sie es an den Haupt-layout:
dann, wenn Sie ändern möchten, können Sie ihn entfernen:
und fügen Sie eine weitere auf die gleiche Weise.
Dieser arbeiten wird, weil Sie möchten, fügen Sie dem layout als das Letzte child-Element des parent-Layouts. Wenn Sie möchten, fügen Sie es, sagen wir, in 1. position, Sie können Blasen Sie Ihre layout ohne Befestigung an der Mutter (verwenden
false
als zuletzt arg) und hinzufügen manuell die Angabe des index:InformationsquelleAutor der Antwort bigstones
Ich bin mir nicht sicher, ob ich wirklich verstanden hatte was Sie ment: "ich kann nicht nur das layout, wie werde ich diese Methode verwenden, aufblasen, um andere layouts in wire frames später auf."
Aber wenn Sie das zweite layout gestellt werden, vielfach in verschiedenen anderen layouts verwenden
<include layout="@layout/the_second_layout" />
in diesen anderen layouts.InformationsquelleAutor der Antwort ernazm