@Override public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) { //leave this empty } @Override public void onScrollStateChanged(AbsListView listView, int scrollState) { if (scrollState == SCROLL_STATE_IDLE) { if (listView.getLastVisiblePosition() >= listView.getCount() - 1 - threshold) { currentPage++; //load more list items: loadElements(currentPage); } } }
private void checkScrolledBottom(AbsListView view, int scrollState){ int cc = view.getCount(); int last = view.getLastVisiblePosition(); if(scrollState == OnScrollListener.SCROLL_STATE_IDLE && cc == last + 1){ if(last != lastBottom){ lastBottom = last; invoke(view, scrollState); } }else{ lastBottom = -1; } }
@Override public void onScrollStateChanged(AbsListView view, int scrollState) { if (scrollState == AbsListView.OnScrollListener.SCROLL_STATE_IDLE) { if (view.getLastVisiblePosition() == view.getCount() - 1 && !ViewCompat.canScrollVertically(view, 1)) { swipeToLoadLayout.setLoadingMore(true); } } }
public boolean canScrollListDown() { // Ported from AbsListView#canScrollList() which isn't compatible to all API levels final int childCount = mView.getChildCount(); final int itemsCount = mView.getCount(); final int firstPosition = mView.getFirstVisiblePosition(); final int lastPosition = firstPosition + childCount; final int lastBottom = mView.getChildAt(childCount - 1).getBottom(); return lastPosition < itemsCount || lastBottom > mView.getHeight() - mView.getListPaddingBottom(); } }
private void fillByListView(final List<ImageView> originImageList) { AbsListView absListView = transConfig.getListView(); int childCount = absListView.getChildCount(); for (int i = 0; i < childCount; i++) { ImageView originImage = ((ImageView) absListView.getChildAt(i) .findViewById(transConfig.getImageId())); originImageList.add(originImage); } int firstPos = absListView.getFirstVisiblePosition(); int lastPos = absListView.getLastVisiblePosition(); int totalCount = absListView.getCount(); fillPlaceHolder(originImageList, totalCount, firstPos, lastPos); }
int listCount = absListView.getCount(); int lastVisiblePosition = absListView.getLastVisiblePosition();
final int lastItemPosition = mRefreshableView.getCount() - 1; final int lastVisiblePosition = mRefreshableView.getLastVisiblePosition();
@Override public int getCount() { return mAbsListView.getCount(); }
@Override public void onScrollStateChanged(AbsListView listView, int scrollState) { if (scrollState == SCROLL_STATE_IDLE) { if (listView.getLastVisiblePosition() >= listView.getCount()-1) { //scroll reached the end, trigger the method to load more itens! } } }
@Override public void onScrollStateChanged(AbsListView view, int scrollState) { if (view.getLastVisiblePosition() == view.getCount() - 1) { checkLoadMore(); } }
@Override public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) { if (view.getLastVisiblePosition() == view.getCount() - 1) { checkLoadMore(); } }
@Override public boolean isScrolledToTop(View view) { AbsListView absListView = (AbsListView) view; if (absListView.getCount() == 0) { return true; } else if (absListView.getFirstVisiblePosition() == 0) { final View firstVisibleChild = absListView.getChildAt(0); return firstVisibleChild != null && firstVisibleChild.getTop() >= 0; } return false; }
@Override public boolean isScrolledToBottom(View view) { AbsListView absListView = (AbsListView) view; if (absListView.getCount() == 0) { return true; } else if (absListView.getLastVisiblePosition() == absListView.getCount() - 1) { final View lastVisibleChild = absListView.getChildAt(absListView.getChildCount() - 1); return lastVisibleChild != null && lastVisibleChild.getBottom() <= absListView.getMeasuredHeight(); } return false; }
protected String selectQuoteText(SparseBooleanArray postPos) { for (int i = 0; i < absListView.getCount(); i++) { if (!postPos.get(i)) continue; return selectQuoteText(i); } return ""; }
private void checkScrolledBottom(AbsListView view, int scrollState){ int cc = view.getCount(); int last = view.getLastVisiblePosition(); if(scrollState == OnScrollListener.SCROLL_STATE_IDLE && cc == last + 1){ if(last != lastBottom){ lastBottom = last; invoke(view, scrollState); } }else{ lastBottom = -1; } }
@Override public void onScrollStateChanged(AbsListView view, int scrollState) { if (scrollState == OnScrollListener.SCROLL_STATE_IDLE && view.getLastVisiblePosition() + 1 == view.getCount()) {// 如果滚动到最后一行 if (onScrollBottomListener != null) { onScrollBottomListener.onScorllBootom(); } } }
@Override public void onScrollStateChanged(AbsListView listView, int scrollState) { if (scrollState == OnScrollListener.SCROLL_STATE_IDLE && listView.getLastVisiblePosition() + 1 == listView.getCount()) {// 如果滚动到最后一行 if (onScrollBottomListener != null) { onScrollBottomListener.onScorllBootom(); } } }
@Override public boolean canOverStart() { if (absListView.getCount() == 0) { return true; } else if (absListView.getFirstVisiblePosition() == 0 && absListView.getChildAt(0).getTop() >= absListView.getPaddingTop()) { return true; } return false; }
private boolean canScrollListDown() { // Ported from AbsListView#canScrollList() which isn't compatible to all API levels final int childCount = mView.getChildCount(); final int itemsCount = mView.getCount(); final int firstPosition = mView.getFirstVisiblePosition(); final int lastPosition = firstPosition + childCount; final int lastBottom = mView.getChildAt(childCount - 1).getBottom(); return lastPosition < itemsCount || lastBottom > mView.getHeight() - mView.getListPaddingBottom(); } }
public boolean isListViewReachBottomEdge(final AbsListView listView) { boolean result = false; if (listView.getLastVisiblePosition() == (listView.getCount() - 1)) { final View bottomChildView = listView.getChildAt(listView.getLastVisiblePosition() - listView.getFirstVisiblePosition()); result = (listView.getHeight() >= bottomChildView.getBottom()); } return result; }