官方Wiki:https://github.com/libgdx/libgdx/wiki/Simple-text-input
实现接口TextInputListener
public class MyTextInputListener implements TextInputListener {
@Override
public void input (String text) {
}
@Override
public void canceled () {
}
}
在用户输入的时候,会触发input()方法。
在用户关闭对话框或者按返回键时,会触发canceled()方法。
MyTextInputListener listener = new MyTextInputListener();
Gdx.input.getTextInput(listener, "Dialog Title", "Initial Textfield Value","hint");
listener方法将在绘制线程内调用。在ApplicationListener.render()
之前调用。