littleK littleK - 27 days ago 7
Java Question

Android dynamically generating tables

I have an Android activity which has a header, some title text, and then I want to dynamically generate a given number of tables. In addition, I want to be able to scroll down to view all of the tables on the activity (not scroll the individual tables). Is this possible? If so, can someone provide me with some guidance?

If not, the only other thing that I can think of is a list view. However my problem here is that I don't want the list view look and feel. I want a "break" between the different groupings of information. So, for example:

-------------------
| January 7, 2010 |
-------------------
| Item #1 |
| Item #2 |
-------------------

-------------------
| January 8, 2010 |
-------------------
| Item #1 |
| Item #2 |
| Item #3 |
-------------------

etc...


Does anyone have any ideas?

Answer

What you want is actually... a TableLayout! The contents of a TableRow can be anything, including other tables. To create space between them, just add a TableRow with an empty View, sized to the height of the number of pixels that you need.

To make the whole thing scrollable, wrap the TableLayout in a ScrollView.