當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。