1

我已经存储了 onLoad 的值,之后我更改了小部件属性,并且在卸载之前再次我想设置以前存储的值,我该怎么办?widget.addAttachHandler(EventHandler) 对我有帮助吗?

4

1 回答 1

0

只需简单地使用事件侦听器设计您自己的小部件。并在您的自定义小部件类中使用 ovveride 加载和卸载方法。

// This method is called when a widget is attached to the browser's document
  @Override
  protected void onLoad() {
    setEventListener(inputElem, this);
    // ... 
  }  


  // This method is called when a widget is detached from the browser's document 
  @Override   protected void onUnload() {
    // Clear out the inputElem's event listener (breaking the circular
    // reference between it and the widget); avoid memory leaks
    setEventListener(inputElem, null);
    // ...
  }
于 2013-06-21T10:23:55.297 回答