gerade verwende ich in meiner Anwendung Tabhost mit einzelnen Aktivitäten und separaten Ansichten.Ändern der Ansicht in TabHost (eine Aktivität, mehrere Ansichten)
Tab Aktivität:
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
TabHost tabs = (TabHost) findViewById(R.id.tabhost);
tabs.setup();
TabHost.TabSpec spec = tabs.newTabSpec(TAB_HOTELS);
spec.setContent(R.id.tab1);
spec.setIndicator("Hotels");
tabs.addTab(spec);
spec = tabs.newTabSpec(TAB_LAST_MINUTE);
spec.setContent(R.id.tab2);
spec.setIndicator("Last Minute");
tabs.addTab(spec);
Layout-
<?xml version="1.0" encoding="utf-8"?>
<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/tabhost" android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout android:orientation="vertical"
android:layout_width="fill_parent" android:layout_height="fill_parent">
<TabWidget android:id="@android:id/tabs"
android:layout_width="fill_parent" android:layout_height="wrap_content" />
<FrameLayout android:id="@android:id/tabcontent"
android:layout_width="fill_parent" android:layout_height="fill_parent">
<LinearLayout android:layout_width="fill_parent"
android:layout_height="fill_parent" android:id="@+id/tab1"
android:orientation="vertical">
<ListView android:id="@+id/listaLocalita"
android:layout_width="fill_parent" android:layout_height="wrap_content" />
</LinearLayout>
<LinearLayout android:layout_width="fill_parent"
android:layout_height="fill_parent" android:id="@+id/tab2"
android:orientation="vertical" android:paddingTop="60px">
<TextView android:layout_width="fill_parent"
android:layout_height="100px" android:text="This is tab 2"
android:id="@+id/txt2" />
</LinearLayout>
</FrameLayout>
</LinearLayout>
</TabHost>
Und die Dinge funktionieren recht gut, solange ich eine Ebene Tiefe bin mit. Leider muss ich jetzt einen der Tabs wie folgt arbeiten:
Tab laden ListView mit der Liste der Städte, User klickt auf Stadtnamen, Tabs Inhalt wird durch die Liste der Hotels ersetzt, Nutzer wählen ein Hotel und immer im selben Tab, wird die Hotelinfo geladen.
Wie kann ich dieses Szenario erreichen? LayoutInfalter?
Vielen Dank im Voraus.
Haben Sie das jemals herausgefunden? Ich suche etwas Ähnliches. –
Siehe nur [dieses Beispiel] (http://ericharlow.blogspot.in/2010/09/experience-multiple-android-activities.html). Hoffe es wird dir helfen. –