Reputation: 1115
Any suggestions on the best way to display this table on an Android platform? The formatting is not necessary but I am looking for a flexible way to do this because there are numerous tables with different numbers of rows and columns.
Upvotes: 0
Views: 3810
Reputation: 1577
Should probably use a TableLayout, it'll be the easiest method. TableLayout only does columns, the TableRow elements are what do columns, so the difference in columns between rows won't matter. You don't have to use TableRow elements in it though, any subclass of View can go in, so you can easily use a LinearLayout set to flow vertically for the top row.
And unless you're going to do some sort of dragging to move to screen, you'll want to place it all within a scrolling layout too, but you've plenty of them to choose from depending on exactly how the table could turn out.
Upvotes: 1
Reputation: 38065
I'd either use a TableLayout wrapped in a ScrollView (or a HorizontalScrollView with a paging control of some sort, if you expect wide tables) or just code your table in HTML and use a WebView. As far as flexibility/reusability, you may want to consider subclassing TableLayout to provide shortcuts for instantiating the table with different options or to let you lay it out in XML while binding behaviors automatically; see the 2nd answer to this SO post for an example.
Upvotes: 1