如何检测 Android ListView 滚动停止? [英] how to detect Android ListView Scrolling stopped?

查看:23
本文介绍了如何检测 Android ListView 滚动停止?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在滚动停止后做一些事情.所以,我尝试使用 OnScrollListener#onScrollStateChanged(SCROLL_STATE_IDLE) 来检测滚动何时停止(TOUCH_SCROLL 或 FLING)(在 1.5 时它按我的预期运行).但是当它在2.0上运行时,松开手指后onScrollStateChanged无法接收事件.是否有任何回调或无论如何检测该事件?

I'm trying to do something after scrolling stopped.So, I tried using OnScrollListener#onScrollStateChanged(SCROLL_STATE_IDLE) to detect when the scrolling stopped(either TOUCH_SCROLL or FLING)(at 1.5 it's runs as i expect). But when it runs on 2.0, onScrollStateChanged can't received the event after releasing the finger.Is there any callback or anyway to detect that event?

推荐答案

尝试使用 setOnScrollListener 并实现 onScrollStateChanged with scrollState == 0 ... do what you need to do...

Try using the setOnScrollListener and implement the onScrollStateChanged with scrollState == 0 ... do what you need to do...

setOnScrollListener(new OnScrollListener() {
    public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
        // TODO Auto-generated method stub
    }

    public void onScrollStateChanged(AbsListView view, int scrollState) {
        if (scrollState == OnScrollListener.SCROLL_STATE_IDLE) {
            Log.i("a", "scrolling stopped...");
        }
    }
});

这篇关于如何检测 Android ListView 滚动停止?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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