当我按照下面的代码片段中显示的方式创建对话框时,如何添加其他小部件(如TextField)?
btnTest.addListener(new ChangeListener()
{
public void changed(ChangeEvent event, Actor actor)
{
new Dialog("Test Dialog", globals.skin, "dialog")
{
protected void result (Object object)
{
if (object.equals(true))
{
if (txtID.getText() != "")
{
globals.appState = AppState.INTRO;
}
}
}
}.text("Enter ID")
.button("Cancel", false)
.button("OK", true)
.show(stage);
}
});
答案 0 :(得分:2)
尝试添加如下默认构造函数:
btnTest.addListener(new ChangeListener()
{
public void changed(ChangeEvent event, Actor actor)
{
new Dialog("Test Dialog", globals.skin, "dialog")
{
{
//Things like this.getButtonTable().add(Actor);
}
protected void result (Object object)
{
if (object.equals(true))
{
if (txtID.getText() != "")
{
globals.appState = AppState.INTRO;
}
}
}
}.text("Enter ID")
.button("Cancel", false)
.button("OK", true)
.show(stage);
}
});