Following are the steps for programmatically adding rows in a TableLayout:
1. Manually include a TableLayout in your main.xml file with an id, say, "TableLayout01". Obtain a reference to the TableLayout as:
table = (TableLayout) findViewById(R.id.TableLayout01);
Note: Ensure to define the variable "table" outside onCreate() inside the class as: TableLayout table;
Android code snippets will be posted on this blog to share them with other developers. These are short and handy code snippets. Screenshots will be included where appropriate to show the expected results when compiled.
Showing posts with label TableLayout. Show all posts
Showing posts with label TableLayout. Show all posts
Wednesday, June 29, 2011
How to display grids on TableLayouts
Android TableLayouts apparently do not have an option to show grids on the tables. In the following example, grid-like appearance is creates by setting margins around each TextView inside the table, and setting different background colors for the TableLayout and the TextViews.
Subscribe to:
Posts (Atom)