简体   繁体   English

将小部件添加到面板的第一个位置?

[英]Add Widget to the a Panel at first Position?

If you want to add a Widget to a lets say FlowPanel you have to do the following: 如果要将小部件添加到可以说的FlowPanel中,则必须执行以下操作:

@UiField
FlowPanel panel;

Widget widget; // some widget

panel.add(widget)

This appends the widget to the panel, which means it comes a last position of the panel's child Widgets. 这会将小部件附加到面板,这意味着它到达面板的子小部件的最后位置。

Ie: 即:

<div>
 <div class="w1" />
 <div class="w2" />
 <div class="w3" />
 <div class="widget" />
</div>

Is there any way to get a newly inserted widget a the first position, ie, make a prepend, without removing all the other widgets first? 有什么方法可以让新插入的窗口小部件成为第一位置,即在不删除所有其他窗口小部件的情况下进行添加?

Is there any way to get a newly inserted widget aa certain index within the parent? 有什么办法可以在父级中的某个索引中获取新插入的小部件吗?

Sure, 当然,

flowPanel.insertWidget(widget, pos);

Use pos = 0 to insert at the first position. 使用pos = 0插入第一个位置。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM