scrollview嵌套listview,获取listview的滑动事件的属性是

scrollview嵌套listview,获取listview的滑动事件的属性是

2个回答

    ListView lv = new ListView(this);
    lv.setOnScrollListener(new AbsListView.OnScrollListener() {
        @Override
        public void onScrollStateChanged(AbsListView view, int scrollState) {
            switch (scrollState) {

                case AbsListView.OnScrollListener.SCROLL_STATE_IDLE:    //当停止滚动时

                    break;

                case AbsListView.OnScrollListener.SCROLL_STATE_TOUCH_SCROLL:    //滚动时

                    break;

                case AbsListView.OnScrollListener.SCROLL_STATE_FLING:   //手指抬起,但是屏幕还在滚动状态

                    break;

            }
        }

        @Override
        public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {

        }
    });

如果是要监听listview的滑动就用lv.setOnScrollListener(OnScrollListener listener)
如果要获取listview滑动了多少就用lv.getScrollY()

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!