1

当我以下面代码片段中显示的方式创建对话框时,如何添加其他小部件(如 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);
  }
});
4

1 回答 1

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);
  }
});
于 2014-06-08T22:29:37.047 回答