SHARE
TWEET
scrollpane and list
a guest
Nov 8th, 2016
57
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
- public class TestScreen extends ScreenAdapter {
- private final LibGDXGame game;
- private Table buttonTable;
- private List<String> gdxList;
- private ScrollPane pane;
- public TestScreen(LibGDXGame game) {
- this.game = game;
- this.create();
- }
- public void create() {
- this.buttonTable = new Table(this.game.skin);
- this.buttonTable.setFillParent(true);
- TextButton button = new TextButton("Add", this.game.skin);
- button.addListener(new ClickListener() {
- @Override
- public void clicked(InputEvent event, float x, float y) {
- TestScreen.this.addItems();
- }
- });
- this.buttonTable.add(button);
- this.buttonTable.row();
- Array<String> strings = new Array<String>();
- for (int i = 0; i < 100; i++) {
- strings.add(String.valueOf(i));
- }
- this.gdxList = new List<String>(this.game.skin);
- this.gdxList.setItems(strings);
- this.pane = new ScrollPane(this.gdxList);
- this.pane.setScrollingDisabled(true, false);
- this.buttonTable.add(this.pane);
- this.game.hudStage.addActor(this.buttonTable);
- }
- private void addItems() {
- for (int i = 0; i < 100; i++) {
- this.gdxList.getItems().add(String.valueOf(i));
- }
- System.out.println("size = " + this.gdxList.getItems().size);
- this.pane.validate();
- }
- }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy.

