【发布时间】:2011-03-07 18:03:07
【问题描述】:
我想实现一个自定义的 TabLayoutPanel,它会在添加小部件时自动设置选项卡本身(使用自定义操作,例如关闭选项卡等)。
我创建了一个 CustomTabPanel.ui.xml 和一个 CustomTabPanel.java。 UI 设计简单地嵌入了一个 TabLayoutPanel,代码部分公开了一些我需要的功能。 我还有一个构造函数,它采用与 TabLayoutPanel 相同的 2 个参数,我想在 UI 设计模式中传递它,就像我对普通 TabLayoutPanel 所做的那样。 看起来是这样的
public class CustomTabPanel extends Composite{
/* ... here all the uiBinder things
already written by my eclipse plugin */
@UiField(provided=true)
TabLayoutPanel tabPanel;
public @UiConstructor CustomTabPanel(double barHeight, Unit barUnit){
tabPanel = new TabLayoutPanl(barHeight, barUnit);
initWidget(uiBinder.creatAndBindUi(this));
}
我在另一个 .ui.xml 文件中使用自定义复合小部件
但是,当我在浏览器中启动和测试网络应用程序时,我收到以下错误:
类 CustomTabPanel 没有合适的 setBarUnit() 方法。 元素
我按照http://code.google.com/intl/fr/webtoolkit/doc/latest/DevGuideUiBinder.html#Using_a_widget 上的说明进行操作。我想我错过了一些东西,但我不知道它是什么。
我之前也尝试过通过创建派生的class ExtendedTabLayoutPanel extends TabLayoutPanel{...} 并使用参数实现构造函数来使用继承。这在运行时给了我另一个错误:
第 xx 行:类型不匹配:无法从 TabLayoutPanel 转换为 ExtendedTabLayoutPanel
希望我说得够清楚了……快读!
【问题讨论】:
标签: xml gwt layout constructor uibinder