问题
I have problem a with getting VLayout
height after I add a member to it
VLayot layout = new VLayout();
in presenter I have code
display.getAnswerPanel().removeMembers(display.getAnswerPanel().getMembers());
which clear all members, and I add another (I have buttons, when I clik them, it clears all VLayout
and adds new members)
layout.addMember(new Button("Example"));
I need to get offsetHeight
of this VLayout
on start and everytime I click the button, my problem is that in first time when I load the page, my `offsetHeigh is 1px, each next time when I click button is ok, it shows me the correct value. Can someone help me?
I tried to use this code
scheduler.get().scheduleDeferred(new Scheduler.ScheduledCommand() {
layout.getOffsetHeight();
}
but the situation is the same, First time I don't have the correct value.
回答1:
we can get the height and width of any widget only after the widget is being loaded or on button click.
回答2:
Scheduler#scheduleDeferred() executes at the end of the GWT loop, so there's still no time for the layout to update either. I guess there's not much you can do besides using the traditional timer hack (in case any reader is in doubt, yes, I meant using setTimeout() or Scheduler.get().scheduleWithFixedDelay(cmd, 200) ).
来源:https://stackoverflow.com/questions/14318080/smartgwt-get-vlayout-height-after-add-members