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!
  1. public class TestScreen extends ScreenAdapter {
  2.    
  3.     private final LibGDXGame game;
  4.    
  5.     private Table buttonTable;
  6.    
  7.     private List<String> gdxList;
  8.    
  9.     private ScrollPane pane;
  10.    
  11.     public TestScreen(LibGDXGame game) {
  12.         this.game = game;
  13.        
  14.         this.create();
  15.     }
  16.    
  17.     public void create() {
  18.        
  19.         this.buttonTable = new Table(this.game.skin);
  20.         this.buttonTable.setFillParent(true);
  21.        
  22.         TextButton button = new TextButton("Add", this.game.skin);
  23.         button.addListener(new ClickListener() {
  24.             @Override
  25.             public void clicked(InputEvent event, float x, float y) {
  26.                 TestScreen.this.addItems();
  27.             }
  28.         });
  29.         this.buttonTable.add(button);
  30.         this.buttonTable.row();
  31.        
  32.         Array<String> strings = new Array<String>();
  33.         for (int i = 0; i < 100; i++) {
  34.             strings.add(String.valueOf(i));
  35.         }
  36.        
  37.         this.gdxList = new List<String>(this.game.skin);
  38.         this.gdxList.setItems(strings);
  39.         this.pane = new ScrollPane(this.gdxList);
  40.         this.pane.setScrollingDisabled(true, false);
  41.         this.buttonTable.add(this.pane);
  42.        
  43.         this.game.hudStage.addActor(this.buttonTable);
  44.     }
  45.    
  46.     private void addItems() {
  47.         for (int i = 0; i < 100; i++) {
  48.             this.gdxList.getItems().add(String.valueOf(i));
  49.         }
  50.        
  51.         System.out.println("size = " + this.gdxList.getItems().size);
  52.        
  53.         this.pane.validate();
  54.     }
  55.  
  56. }
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. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top