Scrolling Listener on Libgdx Scrolling Panel

I use the scroll bar to show a list of items. I want to add a scroll listener on the panel so that I can load more elements dynamically on the panel when it hits the bottom edge;

I tried adding an InputListener and overriding onScroll, but not working for me

+5
source share
2 answers

This is a simple test, I hope I understand your question

In your class.

..// yourScrollPane.addListener(new EventListener() { @Override public boolean handle(Event event) { // TODO Auto-generated method stub System.out.println("Event % "+yourScrollPane.getScrollPercentY()); if(yourScrollPane.getScrollPercentY() == 1f){ addImageButton(); } return false; } }); 

}

 private void addImageButton(){ //Add actor in scroll yourTableInScrollPane.add(button2).row(); yourTableInScrollPane.add(button3).row(); yourTableInScrollPane.add(button4).row(); //table.invalidate(); } 
+2
source

I found another relevant solution that I would like to share:

 ScrollPane scrollPane; Table scrollTable float lastScrollY = 0; . . . scrollTable = new Table(); this.scrollPane = new ScrollPane(scrollTable){ @Override public void act(float delta) { super.act(delta); if(lastScrollY!=scrollPane.getScrollY()){ lastScrollY = scrollPane.getScrollY(); processScrolling(); } } }; 
+1
source

Source: https://habr.com/ru/post/1207971/


All Articles