我已经存储了值onLoad,之后我更改了widget属性,再次卸载之前我想设置以前存储的值,我该怎么办? widget.addAttachHandler(EventHandler)对我有帮助吗?
答案 0 :(得分:0)
只需简单地design your own widget使用事件监听器。在自定义窗口小部件类中,覆盖加载和卸载方法。
// 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);
// ...
}