Bonjour,

J'aimerai pouvoir insérer un TabHost dans mon application, mais le problème est qu'il est situé dans un relativeLayout, et est appelé par un include, ce qui me donne l'erreur suivante :

Caused by: java.lang.RuntimeException: Your content must have a TabHost whose id attribute is 'android.R.id.tabhost'

Voici mon main.xml :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 
	android:id="@+id/relativeLayout1" 
	android:layout_width="fill_parent" 
	android:layout_height="fill_parent"
	android:background="@color/backgroundColor" 
	xmlns:android="http://schemas.android.com/apk/res/android">
	<include
	        layout="@layout/barreprinc"
	        android:id="@+id/barreprinc"
	        android:layout_alignParentTop="true" 
	/>
	<FrameLayout
		android:id="@+id/FrameLayoutAccueil"
		android:layout_width="wrap_content"
		android:layout_height="wrap_content"
		android:layout_centerInParent="true">
		<include
			layout="@layout/pagerechpublication"
		    android:id="@+id/milieu"
		/>
	</FrameLayout>
[...]
</RelativeLayout>
Et mon pagerechpublication.xml :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
<?xml version="1.0" encoding="utf-8"?>
<TabHost
	xmlns:android="http://schemas.android.com/apk/res/android"
	android:id="@android: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"
	android:padding="5dp">
 
	<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">
 
	</FrameLayout>
</LinearLayout>
 
</TabHost>
Enfin, voici mon application principale :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
public class irdesApplication extends TabActivity {
 
    public static final String LOG_TAG="Droidnova";
    ListView listViewActu;
    List<Actualite> listeActu = new ArrayList<Actualite>();
 
 
 
    public void onCreate(Bundle savedInstanceState) {
 
        super.onCreate(savedInstanceState);
        setContentView(R.layout.tab);
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        String valeur = getIntent().getStringExtra("valeur");
        TextView textView = (TextView) findViewById(R.id.monTextView);
        textView.setText(valeur);
 
        //constitution des logs
        int logParam =0;
        Log.v(LOG_TAG, "logParam value" + logParam);
 
 
        listViewActu = (ListView)findViewById(R.id.listViewActu);
        Actualite actu1 = new Actualite("Titre1", "Description de l'actualité");
        Actualite actu2 = new Actualite("Titre2", "Description de l'actualité");
 
	listeActu.add(actu1);
	listeActu.add(actu2);
 
	ActuAdapter adapter = new ActuAdapter(this, listeActu);
	listViewActu.setAdapter(adapter);
 
 
 
    }
}
Comment résoudre le problème ?