Bonjour,

le but de mon bout de programme ci-dessous permet de créer une seule ligne sous le format d'un tableau, par la suite viendra se rajouter plusieurs lignes.

Problème:
Mais je ne vois pas où j'ai pu me tromper dans le code.
Lors du test du code aucune erreur dans le logcat mais aucun affichage
j'ai juste l'image de fond de mon linearlayout.

Pour info --> Je me trouve dans un fragment d'où l'utilisation de getActivity()


Fichier 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
 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity" 
    android:orientation="vertical"
    android:background="@drawable/fond"
    android:id="@+id/LayoutBelotte">
 
    <Space
         android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_weight="1"/>
    <Button
        android:id="@+id/btnInfoPartie"
        android:onClick="commncerPartie"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center_horizontal"/>
    <Space
         android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_weight="1"/>
 
</LinearLayout>

Le code mis en commentaire s'affiche bien. (c'est un exemple)
Fichier Java
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
 
                LinearBelotte1=(LinearLayout)v.findViewById(id.LayoutBelotte); // situe dans la methode onCreateView(....)
                LinearBelotte1.removeAllViewsInLayout();
		LinearBelotte1.setOrientation(LinearLayout.VERTICAL);
 
		/*
		LinearLayout.LayoutParams TEST = new LinearLayout.LayoutParams(LinearLayout.LayoutParams. FILL_PARENT ,LinearLayout.LayoutParams. FILL_PARENT) ;
		TextView test = new TextView(getActivity());
		test.setText("S'affiche bien");
		LinearBelotte1.addView(test,TEST);
		*/
 
		LinearLayout.LayoutParams TEST = new LinearLayout.LayoutParams(LinearLayout.LayoutParams. FILL_PARENT ,LinearLayout.LayoutParams. FILL_PARENT) ;
		LinearLayout.LayoutParams TEST1 = new LinearLayout.LayoutParams(LinearLayout.LayoutParams. FILL_PARENT ,LinearLayout.LayoutParams. WRAP_CONTENT) ;
		LinearLayout.LayoutParams TEST2 = new LinearLayout.LayoutParams(LinearLayout.LayoutParams. FILL_PARENT ,LinearLayout.LayoutParams. FILL_PARENT) ;
		TEST2.setMargins(2, 2, 2, 2);
 
	    tabDefautCapteur1= new TableLayout(getActivity());
	    tabDonnees1 = new TableRow(getActivity());
	    tabDonnees1.setLayoutParams(TEST1);
 
	    tabDonnees1.addView(generateTextView("Heures", TEST2,0));
	    tabDonnees1.addView(generateTextView("Capteur", TEST2,0));
	    tabDonnees1.addView(generateTextView("N°", TEST2,0));
	    tabDonnees1.addView(generateTextView("Donnees", TEST2,0));
	    tabDonnees1.addView(generateTextView("Rafraichissement", TEST2,0));
 
	    // On attribut a la ligne du tableau les différentes cases crées
	    tabDefautCapteur1.addView(tabDonnees1,TEST2);
	    LinearBelotte1.addView(tabDefautCapteur1,TEST);
Merci a tous ceux qui pourront m'aider