[Flextable1] [Flextable2]
[Flextable3] [Flextable4]
在每个flextable内:放置垂直面板
在每个verticalpanel内:由标签和链接组成,如下图所示:
我想在flextable中使用for循环,但我不知道从哪里开始。
请帮我解决。感谢。
答案 0 :(得分:0)
这是一个非常简单的代码。阅读内联评论以获取更多信息。
// root flex table that contains other widgets
FlexTable rootFlexTable = new FlexTable();
int counter = 0;
// 2 rows and 2 columns (change it as per your requirement)
for (int i = 0; i < 2; i++) { // rows
for (int j = 0; j < 2; j++) {// columns
counter++;
FlexTable flexTable = new FlexTable();
VerticalPanel verticalPanel = new VerticalPanel();
Label label = new Label("No " + counter + "(label)");
Hyperlink hyperlink = new Hyperlink("Name " + counter + "(link)",
"link" + counter);
verticalPanel.add(label);
verticalPanel.add(hyperlink);
// why are you using one extra flex table
// that contains only single component?
flexTable.setWidget(0, 0, verticalPanel);
// add inner flex table at row i and column j
rootFlexTable.setWidget(i, j, flexTable);
}
}
RootPanel.get().add(rootFlexTable);
截图: