I have several distinct View
objects, stored in the views
array, that I want to show together on the screen. Therefore, as far as I understand it correctly, a TableView
would do exactly that. However, I can only see one of the views, i.e. like there is a single row, not to rows. Here goes my code:
class myApp extends Activity {
FrameLayout mainFrame = ...;
View[] views = ...;
...
TableLayout grid = new TableLayout(this);
for (int i = 0; i < views.length; i++) {
TableRow row = new TableRow(this);
row.addView(views[i]);
grid.addView(row);//, i);
开发者_如何学运维 }
mainFrame.addView(grid, 1);
UPDATE
Turns out the previous code actually didn't show anything.
I can see something only if I don't use TableRow
, but then I'd get one row only, i.e.:
class myApp extends Activity {
FrameLayout mainFrame = ...;
View[] views = ...;
...
TableLayout grid = new TableLayout(this);
for (int i = 0; i < views.length; i++) {
grid.addView(views[i]);
}
mainFrame.addView(grid, 1);
Any help would be highly appreciated! Thanks!
Try using
grid.setOrientation(TableLayout.VERTICAL)
精彩评论