Salut tout le monde, j'aimerais afficher des commentaires que je récupère de ma BDD dans un tablerow, je récupère bien les données de la base de données avec mes commentaires mais parcontre rien ne s affiche dans mon activité a part le titre de la page et vu que je ne vois rien de suspect dans mon logcat je galère a trouver l erreur :S je suis habituer à n'utiliser que du xml et vu que la je déclare mes Textview, tablerow etc dans mon code java peut etre que j'ai oublié de déclarer quelque chose :S

En suivant un tuto j'en suis arrivé à ca :

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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
 
 
public class PIComments extends Activity{
 
	  public static final String EXTRA_IDPI="EXTRA_IDPI";
	  TableLayout messagesTable;
 
		@Override
		protected void onCreate(Bundle savedInstanceState) {
			// TODO Auto-generated method stub
			super.onCreate(savedInstanceState);
			setContentView(R.layout.picomments);
			messagesTable = (TableLayout)findViewById(R.id.commentTable);
 
			long PIID = getIntent().getLongExtra(EXTRA_IDPI, 0);
 
			if(PIID>0){
 
				ArrayList<CommentMsg> comments = CommentMsg.getPIComments(PIID);
 
				if(comments != null){
 
				    for(int i=0; i<comments.size(); i++) {
 
				    	// Create a TableRow and give it an ID
			            TableRow tr = new TableRow(this);
			            tr.setId(i);
			            tr.setLayoutParams(new LayoutParams(
			                    LayoutParams.FILL_PARENT,
			                    LayoutParams.WRAP_CONTENT));   
 
			            // Create a TextView to house the name of the province
			            TextView login = new TextView(this);
			            login.setId(i);
			            login.setText(comments.get(i).getMsg());
			            //login.setText(comments.get(i).getAuteur());
			            login.setTextColor(Color.BLACK);
			            login.setLayoutParams(new LayoutParams(
			                    LayoutParams.FILL_PARENT,
			                    LayoutParams.WRAP_CONTENT));
			            tr.addView(login);
 
			            // Add the TableRow to the TableLayout
			            messagesTable.addView(tr, new TableLayout.LayoutParams(
			                    LayoutParams.FILL_PARENT,
			                    LayoutParams.WRAP_CONTENT));
 
				    }
				}
				else{
					Dialog d = new Dialog(PIComments.this);
					d.setTitle("No comments for the moment ... ");
					d.show();
				}
			}
 
		}
 
}
avec pour 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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
 
<?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:background="#ffccd0"
    android:orientation="vertical" >
 
    <TextView
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_marginBottom="5dp"
        android:background="#ffb0b6"
        android:text="Comments"
        android:textColor="#b3000d"
        android:textSize="26dp"
        android:textStyle="bold" />
 
    <LinearLayout
        android:id="@+id/ll_country"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent" >
 
        <ScrollView
            android:id="@+id/ScrollView11"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:fillViewport="true" >
 
            <LinearLayout
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_margin="5dp" >
 
                <TableLayout
                    xmlns:android="http://schemas.android.com/apk/res/android"
                    android:id="@+id/commentTable"
                    android:layout_width="fill_parent"
                    android:layout_height="fill_parent"
                    android:stretchColumns="0" >
                </TableLayout>
 
            </LinearLayout>
        </ScrollView>
    </LinearLayout>
 
</LinearLayout>
Voilà merci d'avance de m'aider !