在 GWT 列表框中添加列表

发布于 2024-11-09 02:21:26 字数 549 浏览 0 评论 0原文

我添加了一个列表框,并且有一个需要在列表框中填充的值列表。我能找到的将值添加到列表框的唯一选项是 listbox.addItem... 我必须迭代我拥有的值列表并需要将其一一添加。有没有其他方法可以在一次调用中添加整个列表??

private final List<Operation> numberComparisons = Arrays.asList(Operation.EQUAL, Operation.GREATER_THAN, Operation.GREATER_THAN_OR_EQUAL, Operation.LESS_THAN, Operation.LESS_THAN_OR_EQUAL, Operation.FILLED_IN, Operation.EMPTY);

现在我必须将此数字比较列表添加到

ListBox conditionDropDown = new ListBox();
conditionDropDown.addItem(numberComparisons);

......我该怎么做......???

I have added an List box and and i have an list of value that needs to be populated in the list box. The only option i could find to add values to the list box is listbox.addItem... where i have to iterate the list of values i have and need to add it one by one. Is there any other way where i can add the entire list in one single call.??

private final List<Operation> numberComparisons = Arrays.asList(Operation.EQUAL, Operation.GREATER_THAN, Operation.GREATER_THAN_OR_EQUAL, Operation.LESS_THAN, Operation.LESS_THAN_OR_EQUAL, Operation.FILLED_IN, Operation.EMPTY);

now i have to add this number comparisons list into

ListBox conditionDropDown = new ListBox();
conditionDropDown.addItem(numberComparisons);

..... how can i do this...???

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

亚希 2024-11-16 02:21:26

也许试试这个:

class MyListBox extends ListBox {

    public void addAsList(List<Operation> list) {
        for (Operation operation : Operation.values()) {
            addItem(operation.toString());
    }
}

最后:

MyListBox conditionDropDown = new MyListBox();
conditionDropDown.addAsList(numberComparisons);

Maybe try this:

class MyListBox extends ListBox {

    public void addAsList(List<Operation> list) {
        for (Operation operation : Operation.values()) {
            addItem(operation.toString());
    }
}

and finally:

MyListBox conditionDropDown = new MyListBox();
conditionDropDown.addAsList(numberComparisons);
柳若烟 2024-11-16 02:21:26

查看 ValueListBox 小部件;然后,您将使用 Renderer 来“生成”您的 OperationString 表示形式(用于在列表中向用户显示它们) 。

Have a look at the ValueListBox widget; you'll then use a Renderer to "generate" the String representation of your Operation (used to display them to the user in the list).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文