滚动窗格Libgdx上的滚动侦听器 [英] Scroll Listener on Scroll Pane Libgdx

查看:83
本文介绍了滚动窗格Libgdx上的滚动侦听器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用滚动窗格显示项目列表.我想在窗格上添加一个滚动侦听器",以便一旦它碰到底部边缘,就可以动态地将更多项目加载到窗格中;

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;

我尝试添加InputListener并覆盖onScroll,但对我不起作用

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

在课堂上.

..//
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();
}

这篇关于滚动窗格Libgdx上的滚动侦听器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆