This example might help - http://caguilartech.blogspot.com/2009/08/notes-on-android-tablelayouts-and.html
On Nov 25, 10:38 am, Patrick Plaatje <[email protected]> wrote: > Hi there, > > thanks for the response, but i need to add rows to the table dynamically, so > an xm file is not an option i guess. I'm not sure what is wrong with the > code below, but i fixed it just now. I'm now using a LinearLayout instead of > the nested tabel, and it shows fine. Still strange that the cocde below > didn't do what i expected. > > Regards, > > Patrick > > 2009/11/25 jotobjects <[email protected]> > > > > > How are you actually inflating this layout in a View? > > > This seems to be a normal table layout. Is there some reason you > > can't or don't want to use an xml layout file for this? See following > > example - > > >http://developer.android.com/guide/topics/ui/layout-objects.html#tabl... > > > On Nov 25, 1:00 am, Patrick Plaatje <[email protected]> wrote: > > > Hi all, > > > > in my view i have the need to a somewhat different layout. It needs to > > > display a table within each row a cell for a thumbnail and a cell for > > > displaying a title and a description. The title and description should > > > be displayed on top of eachother, so something like: > > > ----------------------------------------------------------------------------- > > > | | > > > title | > > > | thumb | description | > > > | > > > | | > > > ----------------------------------------------------------------------------- > > > > In this case i thought i'd use a nested table layout: > > > > TableLayout tl = (TableLayout) findViewById(R.id.maintable); > > > > int i=0; > > > for (FeedMessage message : f.getMessages()) { > > > // Create a TableRow and give it an ID > > > TableRow tr = new TableRow(this); > > > tr.setId(i); > > > tr.setBackgroundColor(Color.WHITE); > > > tr.setLayoutParams(new TableLayout.LayoutParams( > > > TableLayout.LayoutParams.FILL_PARENT, > > > TableLayout.LayoutParams.FILL_PARENT)); > > > > // setup a new table for the title and the description > > > rows > > > TableLayout table = new TableLayout(this); > > > table.setBackgroundColor(Color.WHITE); > > > table.setShrinkAllColumns(true); > > > table.setLayoutParams(new TableRow.LayoutParams( > > > TableRow.LayoutParams.FILL_PARENT, > > > TableRow.LayoutParams.FILL_PARENT > > > )); > > > > // setup the rows for the textviews > > > TableRow titleRow = new TableRow(this); > > > TableRow descriptionRow = new TableRow(this); > > > > // construct the views > > > TextView titleView = getTitleView(message); > > > TextView descriptionView = getDescriptionView(message); > > > ImageView thumbView = (ImageView) getThumbView(message); > > > > titleRow.addView(titleView); > > > descriptionRow.addView(descriptionView); > > > > table.addView(titleRow); > > > table.addView(descriptionRow); > > > > tr.addView(table); > > > tl.addView(tr); > > > > } > > > > I get no exceptions, messages are real objects, but the table just > > > ain't displaying. Any thoughts? > > > > Regards, > > > > Patrick > > > -- > > You received this message because you are subscribed to the Google > > Groups "Android Developers" group. > > To post to this group, send email to [email protected] > > To unsubscribe from this group, send email to > > [email protected]<android-developers%[email protected]> > > For more options, visit this group at > >http://groups.google.com/group/android-developers?hl=en > > -- > Met vriendelijke groet, > > Patrick Plaatje > > NDC|VBK de uitgevers > Sixmastraat 32, 8915 PA Leeuwarden > Postbus 394, 8901 BD Leeuwarden > T (058) - 284 5044 > M (06) - 158 966 34 -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en

