2010-11-01 16 views
1

J'ai quelques onglets à base de mises en page avec leur propre description xml, mais quand je l'ai essayé de définir le contenu de l'onglet i obtenu un tel résultat:Android: mise en page ne semble pas que le contenu de l'onglet

http://img266.imageshack.us/img266/1787/appnavihist.jpg

(blanc le champ avec le texte fait partie de la disposition home.xml). Voici un code:

TabSpec spec = tabHost.newTabSpec("home").setIndicator("Home").setContent(R.id.LinearLayout_home); 
    tabHost.addTab(spec); 

main.xml:

<?xml version="1.0" encoding="utf-8"?> 

<LinearLayout android:id="@+id/LinearLayout_root" 
android:layout_width="wrap_content" 
android:layout_height="wrap_content"> 

    <TabWidget android:id="@android:id/tabs" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content"> 
    </TabWidget> 

    <FrameLayout android:id="@android:id/tabcontent" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent"> 
     <include layout="@layout/home"/> 
    </FrameLayout>  

</LinearLayout> 

+0

Semble bien. Peut poster le contenu des mises en page xml? –

+0

sûr .. (principal) http://pastie.org/1263646 (accueil) http://pastie.org/1263648 – polyakovsky

+0

La prochaine fois que vous essayez de coller tous les éléments connexes directement à stackoverflow pour le rendre plus facile pour les autres utilisateurs de trouver le vérité :) –

Répondre

2

Je pense que votre problème est avec la mise en page qui contient tabwidget élément, essayez d'ajouter android:orientation="vertical" propriété à le conteneur tabwidget:

<LinearLayout android:id="@+id/LinearLayout_root" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:orientation="vertical"> 

modèle android par défaut pour TabActivity ressemble à ceci:

<TabHost xmlns:android="http://schemas.android.com/apk/res/android" android:id="@android:id/tabhost" 
android:layout_width="match_parent" android:layout_height="match_parent"> 
    <LinearLayout android:orientation="vertical" 
    android:layout_width="match_parent" android:layout_height="match_parent"> 
     <TabWidget android:id="@android:id/tabs" android:layout_width="match_parent" 
      android:layout_height="wrap_content" android:layout_weight="0" /> 
     <FrameLayout android:id="@android:id/tabcontent" 
      android:layout_width="match_parent" android:layout_height="0dip" 
      android:layout_weight="1"/> 
    </LinearLayout> 
</TabHost> 

Je suppose que cela devrait fonctionner pour vous aussi.

+0

a obtenu le même résultat ... – polyakovsky

+0

Ajout de la mise en œuvre de la plate-forme Android par défaut. –

+0

merci pour l'aide :) ça marche :) – polyakovsky

0

son fonctionnement .. j'ai essayé ..

<TabWidget android:id="@android:id/tabs" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent"> 
    </TabWidget> 

mais je reçois Xactly que mon exigence avec ce

<TabWidget android:id="@android:id/tabs" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content"> 
    </TabWidget> 

[pour enlever l'espace supplémentaire ci-dessous de tabhost]

code