I am using a scroll pane to show a list of items. I want to add a Scroll Listener on the pane so that I can load more items Dynamically to the pane once it hits the bottom edge;
I tried to add an InputListener and override onScroll but is not working for me
this is a simple test, I hope I understood 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();
}
I found another relevant solution which 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();
}
}
};
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With