我有一个问题:几个选项卡,打开一个新选项卡,在其中进行一些活动后,它被关闭。问题是我TabSelectedHandler
在 every 上也有 s Tab
,它们不仅被执行onTabSelected
,而且在删除时也被执行(这恰好是一个问题)。删除最后一个选项卡时,将选择上一个选项卡。如何避免这种情况并且只删除?以下是代码示例:
Tab existingTab0 = new Tab("Static tab 0");
existingTab0.setID("0");
existingTab0.addTabSelectedHandler(new TabSelectedHandler () {
public void onTabSelected(final TabSelectedEvent event) {
// do stuff 0
}
});
Tab existingTab1 = new Tab("Static tab 1");
existingTab1.setID("1");
existingTab1.addTabSelectedHandler(new TabSelectedHandler () {
public void onTabSelected(final TabSelectedEvent event) {
// do stuff 1
}
});
Tab dynamicTab = new Tab("Dynamic tab");
dynamicTab.setID("2");
dynamicTab.addTabSelectedHandler(new TabSelectedHandler () {
public void onTabSelected(final TabSelectedEvent event) {
// do stuff 2
}
});
TabSet tabSet = new TabSet();
tabSet.addTab(existingTab0);
tabSet.addTab(existingTab1);
tabSet.addTab(dynamicTab);
// upon a specific case I need to remove dynamicTab
tabSet.removeTab(dynamicTab); // forces onTabSelected method for Static tab 1 to be fired and does stuff 1 and this should NOT happen here
任何解决方法的想法?提前致谢。