Rows added to table are not showing up

Posted by Lars on Stack Overflow See other posts from Stack Overflow or by Lars
Published on 2011-01-31T15:25:05Z Indexed on 2011/01/31 15:25 UTC
Read the original article Hit count: 246

Filed under:
|

This has been asked before, but I have found no solution that worked for me yet:

When adding rows to a table from code, the rows are not showing up in the application. There is one row I specified in XML, that one is showing up, but nothing below it.

This is the code:

public void addRow(LocationMessage locationMsg){
  View messageView = theInflater.inflate(R.layout.homepage, null);
  TableLayout table = (TableLayout)messageView.findViewById(R.id.distanceTable);

  TextView senderNameTextView = new TextView(thisContext);
  senderNameTextView.setText(locationMsg.getSenderName());

  TableRow tr = new TableRow(thisContext);
  tr.addView(distanceTextView);
  table.addView(tr);
  rows.addFirst(messageView);
}

homepage.xml contains this, I removed some elements and parameters:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout>
    <TabHost>
    <TabWidget />
        <FrameLayout>
        [..]        
            <LinearLayout>          
            [..]
                <TableLayout
                android:id="@+id/distanceTable" 
                android:layout_height="wrap_content"
                android:layout_width="wrap_content"
                android:layout_gravity="center"
                android:background="#DDDDDD"
                android:stretchColumns="1" >
                    <TableRow>
                        <TextView
                        android:textColor="#000000"
                        android:text="@string/label_device"
                        android:layout_gravity="center"
                        android:padding="3dip"
                        android:textSize="18sp" />
                        <TextView
                        android:textColor="#000000"
                        android:text="@string/label_distance"
                        android:layout_gravity="center"
                        android:padding="3dip"
                        android:textSize="18sp" />
                        <TextView
                        android:textColor="#000000"
                        android:text="@string/label_time"
                        android:layout_gravity="center"
                        android:padding="3dip"
                        android:textSize="18sp" />
                    </TableRow>
                </TableLayout>
            </LinearLayout>
        </FrameLayout>
    </TabHost>
</LinearLayout>

Unfortunately hierarchyviewer.bat doesn't work for me in order to check if the rows are there but just not visible. In the debugger it looks fine to me.

© Stack Overflow or respective owner

Related posts about android

Related posts about table