Ich versuche, eine Aktivität mit 3 Tabs darauf zu implementieren. Ich entschied mich, FragmentTabHost für diesen Zweck zu verwenden.Muss FragmentTabHost TabWidget explizit definiert werden
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<android.support.v4.app.FragmentTabHost
android:id="@android:id/tabhost"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TabWidget
android:id="@android:id/tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"/>
</android.support.v4.app.FragmentTabHost>
<FrameLayout
android:id="@+id/realtabcontent"
android:layout_width="match_parent"
android:layout_height="match_parent"
/>
</LinearLayout>
Aber ich war überrascht, als selbstverständlich, dass vorherige Codebeispiel auf die gleiche Weise ohne TabWidget funktioniert: Ich habe einige Code-Beispiele mit folgenden Layout-Datei gefunden
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<android.support.v4.app.FragmentTabHost
android:id="@android:id/tabhost"
android:layout_width="match_parent"
android:layout_height="wrap_content">
</android.support.v4.app.FragmentTabHost>
<FrameLayout
android:id="@+id/realtabcontent"
android:layout_width="match_parent"
android:layout_height="match_parent"
/>
</LinearLayout>
ich meine Tabs nur sehen, wie beabsichtigt . Gemäß dem Quellcode für FragmentTabHost erstellt es TabWidget von selbst, wenn es in der Hierarchie der Ansichten nicht gefunden werden konnte. Also frage ich mich, ob ich TabWidget explizit in meiner Layout-Datei deklarieren sollte oder nicht.
Danke für die schnelle und vollständige Antwort. Du hast recht. In der TabWidget- und FragmentTabHost-Dokumentation fehlen einige Details. –