当前位置: 首页>>代码示例>>Java>>正文


Java AbsListView.OnScrollListener方法代码示例

本文整理汇总了Java中android.widget.AbsListView.OnScrollListener方法的典型用法代码示例。如果您正苦于以下问题:Java AbsListView.OnScrollListener方法的具体用法?Java AbsListView.OnScrollListener怎么用?Java AbsListView.OnScrollListener使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.widget.AbsListView的用法示例。


在下文中一共展示了AbsListView.OnScrollListener方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setAbsListViewOnScrollListener

import android.widget.AbsListView; //导入方法依赖的package包/类
private void setAbsListViewOnScrollListener(AbsListView absListView) {
    if (absListView != null) {
        try {
            // 通过反射获取滚动监听器,设置自己的滚动监听器后通知之前已有的监听
            Field field = AbsListView.class.getDeclaredField("mOnScrollListener");
            field.setAccessible(true);
            // 开发者自定义的滚动监听器
            AbsListView.OnScrollListener onScrollListener = (AbsListView.OnScrollListener) field.get(absListView);
            if (absListViewScrollListener == null) {
                absListViewScrollListener = new AbsListViewScrollListener();
            }
            if (onScrollListener != absListViewScrollListener){
                absListViewScrollListener.setOriginalListener(onScrollListener);
                absListView.setOnScrollListener(absListViewScrollListener);
            }
        } catch (Exception e) {
            Log.e(TAG, "反射获取AbsListView#OnScrollListener异常", e);
        }
    }
}
 
开发者ID:excitedhaha,项目名称:RefreshLoadLayout,代码行数:21,代码来源:RefreshLoadLayout.java

示例2: setAbsListViewOnScrollListener

import android.widget.AbsListView; //导入方法依赖的package包/类
private void setAbsListViewOnScrollListener() {
    if (mAbsListView != null) {
        try {
            // 通过反射获取开发者自定义的滚动监听器,并将其替换成自己的滚动监听器,触发滚动时也要通知开发者自定义的滚动监听器(非侵入式,不让开发者继承特定的控件)
            // mAbsListView.getClass().getDeclaredField("mOnScrollListener")获取不到mOnScrollListener,必须通过AbsListView.class.getDeclaredField("mOnScrollListener")获取
            Field field = AbsListView.class.getDeclaredField("mOnScrollListener");
            field.setAccessible(true);
            // 开发者自定义的滚动监听器
            final AbsListView.OnScrollListener onScrollListener = (AbsListView.OnScrollListener) field.get(mAbsListView);
            mAbsListView.setOnScrollListener(new AbsListView.OnScrollListener() {
                @Override
                public void onScrollStateChanged(AbsListView absListView, int scrollState) {
                    if ((scrollState == SCROLL_STATE_IDLE || scrollState == SCROLL_STATE_FLING) && shouldHandleAbsListViewLoadingMore(mAbsListView)) {
                        beginLoadingMore();
                    }

                    if (onScrollListener != null) {
                        onScrollListener.onScrollStateChanged(absListView, scrollState);
                    }
                }

                @Override
                public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
                    if (onScrollListener != null) {
                        onScrollListener.onScroll(view, firstVisibleItem, visibleItemCount, totalItemCount);
                    }
                }
            });
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:34,代码来源:BGARefreshLayout.java

示例3: RecyclerToListViewScrollListener

import android.widget.AbsListView; //导入方法依赖的package包/类
public RecyclerToListViewScrollListener(AbsListView.OnScrollListener scrollListener) {
  this.scrollListener = scrollListener;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:4,代码来源:RecyclerToListViewScrollListener.java

示例4: setOnScrollListener

import android.widget.AbsListView; //导入方法依赖的package包/类
public void setOnScrollListener(AbsListView.OnScrollListener onScrollListener) {
    this.onScrollListener = onScrollListener;
}
 
开发者ID:abook23,项目名称:godlibrary,代码行数:4,代码来源:ListViewRefresh.java

示例5: setOnScrollListener

import android.widget.AbsListView; //导入方法依赖的package包/类
public void setOnScrollListener(AbsListView.OnScrollListener onScrollListener) {
        mOnScrollListener = onScrollListener;
}
 
开发者ID:HelloChenJinJun,项目名称:TestChat,代码行数:4,代码来源:FloatingActionsMenu.java

示例6: makeScrollListener

import android.widget.AbsListView; //导入方法依赖的package包/类
/**
 * Return ScrollListener for ListView
 *
 * @return OnScrollListener
 */
public AbsListView.OnScrollListener makeScrollListener() {
    return new AbsListView.OnScrollListener() {

        private boolean isFirstItem = false;
        private boolean isLastItem = false;

        @Override
        public void onScrollStateChanged(AbsListView absListView, int scrollState) {
            setEnabled(scrollState != AbsListView.OnScrollListener.SCROLL_STATE_TOUCH_SCROLL);
            if (swipeClosesAllItemsWhenListMoves && scrollState == SCROLL_STATE_TOUCH_SCROLL) {
                closeOpenedItems();
            }
            if (scrollState == SCROLL_STATE_TOUCH_SCROLL) {
                listViewMoving = true;
                setEnabled(false);
            }
            if (scrollState != AbsListView.OnScrollListener.SCROLL_STATE_FLING && scrollState != SCROLL_STATE_TOUCH_SCROLL) {
                listViewMoving = false;
                downPosition = ListView.INVALID_POSITION;
                swipeListView.resetScrolling();
                new Handler().postDelayed(new Runnable() {
                    public void run() {
                        setEnabled(true);
                    }
                }, 500);
            }
        }

        @Override
        public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
            if (isFirstItem) {
                boolean onSecondItemList = firstVisibleItem == 1;
                if (onSecondItemList) {
                    isFirstItem = false;
                }
            } else {
                boolean onFirstItemList = firstVisibleItem == 0;
                if (onFirstItemList) {
                    isFirstItem = true;
                    swipeListView.onFirstListItem();
                }
            }
            if (isLastItem) {
                boolean onBeforeLastItemList = firstVisibleItem + visibleItemCount == totalItemCount - 1;
                if (onBeforeLastItemList) {
                    isLastItem = false;
                }
            } else {
                boolean onLastItemList = firstVisibleItem + visibleItemCount >= totalItemCount;
                if (onLastItemList) {
                    isLastItem = true;
                    swipeListView.onLastListItem();
                }
            }
        }
    };
}
 
开发者ID:NewCasino,项目名称:browser,代码行数:63,代码来源:SwipeListViewTouchListener.java

示例7: RecyclerToListViewScrollListener

import android.widget.AbsListView; //导入方法依赖的package包/类
public RecyclerToListViewScrollListener(AbsListView.OnScrollListener scrollListener) {
    this.scrollListener = scrollListener;
}
 
开发者ID:hushengjun,项目名称:FastAndroid,代码行数:4,代码来源:RecyclerToListViewScrollListener.java

示例8: setScrollListener

import android.widget.AbsListView; //导入方法依赖的package包/类
/**
 * 设置listview的滚动监听
 */
public void setScrollListener(AbsListView.OnScrollListener mScrollListener) {
    this.mScrollListener = mScrollListener;
}
 
开发者ID:yanyiqun001,项目名称:goRefresh,代码行数:7,代码来源:GoRefreshLayout.java

示例9: setOriginalListener

import android.widget.AbsListView; //导入方法依赖的package包/类
void setOriginalListener(AbsListView.OnScrollListener originalListener) {
    this.originalListener = originalListener;
}
 
开发者ID:excitedhaha,项目名称:RefreshLoadLayout,代码行数:4,代码来源:RefreshLoadLayout.java

示例10: setOnScrollListener

import android.widget.AbsListView; //导入方法依赖的package包/类
public void setOnScrollListener(AbsListView.OnScrollListener l) {
    mExternalOnScrollListener = l;
}
 
开发者ID:smuyyh,项目名称:StickyHeaderListView,代码行数:4,代码来源:StickyHeaderListView.java


注:本文中的android.widget.AbsListView.OnScrollListener方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。