2
\$\begingroup\$

I have a textfield using scene2d but don't know how to save user input. this is what i have and it just draws the textfield.

     txtUsername = new TextField("", mSkin);
     txtUsername.setMessageText("test");
     txtUsername.setPosition(30, 30);
     mStage.addActor(txtUsername);
\$\endgroup\$

1 Answer 1

4
\$\begingroup\$

TextField has a method called getText(), it may never be null but may return an empty string.

txtUsername = new TextField("", mSkin);
txtUsername.setMessageText("test");
txtUsername.setPosition(30, 30);
mStage.addActor(txtUsername);
String test = txtUsername.getText();
System.out.println(test);

http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/scenes/scene2d/ui/TextField.html#text

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .