1

我有和这里一样的问题。

有没有办法覆盖 onResize 方法并在 uibinder 中使用它?

SplitLayoutPanel mainPanel = new SplitLayoutPanel() {
    @Override
    public void onResize() {
        super.onResize();
        //some other resizing stuff
    }           
};
4

1 回答 1

0

是的。定义类:

package com.foo;

public class MySplitLayoutPanel extends SplitLayoutPanel() {
  @Override
  public void onResize() {
    super.onResize();
    //some other resizing stuff
  }           
};

然后将类所在的包绑定到您选择的 xml 命名空间(与UiBinder模板中定义的其他命名空间不冲突):

<ui:UiBinder xmlns:ui='urn:ui:com.google.gwt.uibinder'
             xmlns:g='urn:import:com.google.gwt.user.client.ui'
             xmlns:foo='urn:import:com.foo'>

然后通过命名空间引用你的类(就像你对常用g命名空间的其他小部件一样):

<foo:MySplitLayoutPanel />

这是UiBinder部分内容,但我认为您链接的答案根本不是解决方案,因为onResize()当浏览器窗口调整大小时也会(主要是)调用。

于 2013-04-06T21:55:02.097 回答