當前位置: 首頁>>代碼示例>>Java>>正文


Java AbsListView.getLastVisiblePosition方法代碼示例

本文整理匯總了Java中android.widget.AbsListView.getLastVisiblePosition方法的典型用法代碼示例。如果您正苦於以下問題:Java AbsListView.getLastVisiblePosition方法的具體用法?Java AbsListView.getLastVisiblePosition怎麽用?Java AbsListView.getLastVisiblePosition使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.widget.AbsListView的用法示例。


在下文中一共展示了AbsListView.getLastVisiblePosition方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: isAbsListViewToBottom

import android.widget.AbsListView; //導入方法依賴的package包/類
public static boolean isAbsListViewToBottom(AbsListView absListView) {
    if (absListView != null && absListView.getAdapter() != null && absListView.getChildCount() > 0 && absListView.getLastVisiblePosition() == absListView.getAdapter().getCount() - 1) {
        View lastChild = absListView.getChildAt(absListView.getChildCount() - 1);

        BGAStickyNavLayout stickyNavLayout = getStickyNavLayout(absListView);
        if (stickyNavLayout != null) {
            // 處理BGAStickyNavLayout中lastChild.getBottom() <= absListView.getMeasuredHeight()失效問題

            // 0表示x,1表示y
            int[] location = new int[2];
            lastChild.getLocationOnScreen(location);
            int lastChildBottomOnScreen = location[1] + lastChild.getMeasuredHeight();
            stickyNavLayout.getLocationOnScreen(location);
            int stickyNavLayoutBottomOnScreen = location[1] + stickyNavLayout.getMeasuredHeight();
            return lastChildBottomOnScreen + absListView.getPaddingBottom() <= stickyNavLayoutBottomOnScreen;
        } else {
            return lastChild.getBottom() <= absListView.getMeasuredHeight();
        }
    }
    return false;
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:22,代碼來源:BGARefreshScrollingUtil.java

示例2: canChildScrollDown

import android.widget.AbsListView; //導入方法依賴的package包/類
public static boolean canChildScrollDown(View view) {
    if (android.os.Build.VERSION.SDK_INT < 14) {
        if (view instanceof AbsListView) {
            final AbsListView absListView = (AbsListView) view;
            return absListView.getChildCount() > 0
                    && (absListView.getLastVisiblePosition() < absListView.getChildCount() - 1
                    || absListView.getChildAt(absListView.getChildCount() - 1).getBottom() > absListView.getPaddingBottom());
        } else if (view instanceof ScrollView) {
            ScrollView scrollView = (ScrollView) view;
            if (scrollView.getChildCount() == 0) {
                return false;
            } else {
                return scrollView.getScrollY() < scrollView.getChildAt(0).getHeight() - scrollView.getHeight();
            }
        } else {
            return false;
        }
    } else {
        return view.canScrollVertically(1);
    }
}
 
開發者ID:smartbeng,項目名稱:PaoMovie,代碼行數:22,代碼來源:PtrDefaultHandler2.java

示例3: canScrollDown

import android.widget.AbsListView; //導入方法依賴的package包/類
private static boolean canScrollDown(View mScrollableView) {
    if (android.os.Build.VERSION.SDK_INT < 14) {
        if (mScrollableView instanceof AbsListView) {
            final AbsListView absListView = (AbsListView) mScrollableView;
            return absListView.getChildCount() > 0
                    && (absListView.getLastVisiblePosition() < absListView.getChildCount() - 1
                    || absListView.getChildAt(absListView.getChildCount() - 1).getBottom() > absListView.getPaddingBottom());
        } else {
            return mScrollableView.getScrollY() < 0;
        }
    } else {
        return mScrollableView.canScrollVertically(1);
    }
}
 
開發者ID:Brave-wan,項目名稱:SmartRefresh,代碼行數:15,代碼來源:RefreshContentWrapper.java

示例4: scrollToTop

import android.widget.AbsListView; //導入方法依賴的package包/類
private static boolean scrollToTop(View view) {
    if (Build.VERSION.SDK_INT < 14) {
        if (view instanceof AbsListView) {
            final AbsListView absListView = (AbsListView) view;
            return absListView.getChildCount() > 0
                    && (absListView.getLastVisiblePosition() < absListView.getChildCount() - 1
                    || absListView.getChildAt(absListView.getChildCount() - 1).getBottom() > absListView.getPaddingBottom());
        } else {
            return ViewCompat.canScrollVertically(view, 1) || view.getScrollY() < 0;
        }
    } else {
        return ViewCompat.canScrollVertically(view, 1);
    }
}
 
開發者ID:anmingyu11,項目名稱:OverScrollableRecyclerView-Method1,代碼行數:15,代碼來源:ScrollerUtil.java

示例5: canChildScrollDown

import android.widget.AbsListView; //導入方法依賴的package包/類
public boolean canChildScrollDown() {
    if (android.os.Build.VERSION.SDK_INT < 14) {
        if (mTarget instanceof AbsListView) {
            final AbsListView absListView = (AbsListView) mTarget;
            try {
                if (absListView.getCount() > 0) {
                    if (absListView.getLastVisiblePosition() + 1 == absListView.getCount()) {
                        int lastIndex = absListView.getLastVisiblePosition() - absListView.getFirstVisiblePosition();
                        return absListView.getChildAt(lastIndex).getBottom() == absListView.getPaddingBottom();
                    }
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
            return true;
        } else {
            return true;
        }
    } else {
        return ViewCompat.canScrollVertically(mTarget, 1);
    }
}
 
開發者ID:shenhuanet,項目名稱:AndroidOpen,代碼行數:23,代碼來源:SwipeToRefreshLayout.java

示例6: canChildScrollDown

import android.widget.AbsListView; //導入方法依賴的package包/類
public boolean canChildScrollDown() {
    if (android.os.Build.VERSION.SDK_INT < 14) {
        if (mTarget instanceof AbsListView) {
            final AbsListView absListView = (AbsListView) mTarget;
            View lastChild = absListView.getChildAt(absListView.getChildCount() - 1);
            if (lastChild != null) {
                return (absListView.getLastVisiblePosition() == (absListView.getCount() - 1))
                        && lastChild.getBottom() > absListView.getPaddingBottom();
            } else {
                return false;
            }
        } else {
            return mTarget.getHeight() - mTarget.getScrollY() > 0;
        }
    } else {
        return ViewCompat.canScrollVertically(mTarget, 1);
    }
}
 
開發者ID:838030195,項目名稱:DaiGo,代碼行數:19,代碼來源:PullRefreshLayout.java

示例7: canChildPullUp

import android.widget.AbsListView; //導入方法依賴的package包/類
public boolean canChildPullUp() {
    if (child instanceof AbsListView) {
        AbsListView absListView = (AbsListView) child;
        return canScrollVertically(child, 1)
                || absListView.getLastVisiblePosition() != mTotalItemCount - 1;
    } else if (child instanceof WebView) {
        WebView webview = (WebView) child;
        if (webview instanceof XWebView) {
            return !((XWebView) webview).isBottom();
        } else {
            float left = webview.getContentHeight() * webview.getScale();
            int right = webview.getHeight() + webview.getScrollY();
            return left != right;
        }
    } else if (child instanceof ScrollView) {
        ScrollView scrollView = (ScrollView) child;
        View childView = scrollView.getChildAt(0);
        if (childView != null) {
            return canScrollVertically(child, 1)
                    || scrollView.getScrollY() < childView.getHeight() - scrollView.getHeight();
        }
    } else {
        return canScrollVertically(child, 1);
    }
    return true;
}
 
開發者ID:LonelyMushroom,項目名稱:aarLibrary,代碼行數:27,代碼來源:XRefreshContentView.java

示例8: canChildScrollDown

import android.widget.AbsListView; //導入方法依賴的package包/類
/**
 * Whether child view can scroll down
 * @return
 */
public boolean canChildScrollDown() {
  if (mTargetView == null) {
    return false;
  }
  if (Build.VERSION.SDK_INT < 14) {
    if (mTargetView instanceof AbsListView) {
      final AbsListView absListView = (AbsListView) mTargetView;
      if (absListView.getChildCount() > 0) {
        int lastChildBottom = absListView.getChildAt(absListView.getChildCount() - 1)
            .getBottom();
        return absListView.getLastVisiblePosition() == absListView.getAdapter().getCount() - 1
               && lastChildBottom <= absListView.getMeasuredHeight();
      } else {
        return false;
      }

    } else {
      return ViewCompat.canScrollVertically(mTargetView, 1) || mTargetView.getScrollY() > 0;
    }
  } else {
    return ViewCompat.canScrollVertically(mTargetView, 1);
  }
}
 
開發者ID:erguotou520,項目名稱:weex-uikit,代碼行數:28,代碼來源:WXSwipeLayout.java

示例9: canChildScrollDown

import android.widget.AbsListView; //導入方法依賴的package包/類
/**
 * 是否能上拉
 *
 * @return
 */
private boolean canChildScrollDown() {
    if (checkListener != null) {
        return checkListener.canScrollDown();
    }
    if (android.os.Build.VERSION.SDK_INT < 14) {
        if (child instanceof AbsListView) {
            final AbsListView absListView = (AbsListView) child;
            return absListView.getChildCount() > 0
                    && (absListView.getLastVisiblePosition() < absListView.getChildCount() - 1
                    || absListView.getChildAt(absListView.getChildCount() - 1).getBottom() > absListView.getHeight() - absListView.getPaddingBottom());
        }
    }
    return ViewCompat.canScrollVertically(child, 1);

}
 
開發者ID:zuoweitan,項目名稱:Hitalk,代碼行數:21,代碼來源:OverScrollLayout.java

示例10: onScrollToTopOrBottom

import android.widget.AbsListView; //導入方法依賴的package包/類
private void onScrollToTopOrBottom(AbsListView view) {
    View childAt = view.getChildAt(0);
    if (childAt == null) {
        return;
    }
    //滑動到頂部
    if (view.getFirstVisiblePosition() == 0 &&
            childAt.getTop() >= 0) {
    //It is scrolled all the way up here
        if (mScrollChangeListener != null) {
            mScrollChangeListener.onScrollToTop();
        }
    }

    //滑動到底部
    if (view.getLastVisiblePosition() == view.getAdapter().getCount() - 1 &&
            view.getChildAt(
                    view.getChildCount() - 1).getBottom() <= view.getHeight()) {
        if (mScrollChangeListener != null) {
            mScrollChangeListener.onScrollToBottom();
        }
    }
}
 
開發者ID:hetianpeng,項目名稱:shareApk,代碼行數:24,代碼來源:CalculatorOnScrollListener.java

示例11: canChildScrollDown

import android.widget.AbsListView; //導入方法依賴的package包/類
/**
 * 判斷View是否可以下拉
 * @return canChildScrollDown
 */
public boolean canChildScrollDown() {
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
        if (mTargetView instanceof AbsListView) {
            final AbsListView absListView = (AbsListView) mTargetView;
            return absListView.getChildCount() > 0 && absListView.getAdapter() != null
                    && (absListView.getLastVisiblePosition() < absListView.getAdapter().getCount() - 1 || absListView.getChildAt(absListView.getChildCount() - 1)
                    .getBottom() < absListView.getPaddingBottom());
        } else {
            return ViewCompat.canScrollVertically(mTargetView, 1) || mTargetView.getScrollY() > 0;
        }
    } else {
        return ViewCompat.canScrollVertically(mTargetView, 1);
    }
}
 
開發者ID:joelan,項目名稱:ClouldReader,代碼行數:19,代碼來源:SlidingLayout.java

示例12: onScrollStateChanged

import android.widget.AbsListView; //導入方法依賴的package包/類
@Override
public void onScrollStateChanged(AbsListView view, int scrollState) {
    if (mAdapter == null || mAdapter.getCount() == 0) {
        return;
    }
    // 數據已經全部加載,或數據為空時,或正在加載,不處理滾動事件
    if (mState == STATE_LOADMORE || mState == STATE_REFRESH) {
        return;
    }
    // 判斷是否滾動到底部
    boolean scrollEnd = false;
    try {
        if (view.getPositionForView(mAdapter.getFooterView()) == view
                .getLastVisiblePosition())
            scrollEnd = true;
    } catch (Exception e) {
        scrollEnd = false;
    }

    if (mState == STATE_NONE && scrollEnd) {
        if (mAdapter.getState() == ListBaseAdapter.STATE_LOAD_MORE
                || mAdapter.getState() == ListBaseAdapter.STATE_NETWORK_ERROR) {
            mCurrentPage++;
            mState = STATE_LOADMORE;
            requestData(false);
            mAdapter.setFooterViewLoading();
        }
    }
}
 
開發者ID:hsj-xiaokang,項目名稱:OSchina_resources_android,代碼行數:30,代碼來源:BaseListFragment.java

示例13: canChildScrollDown

import android.widget.AbsListView; //導入方法依賴的package包/類
/**
 * Whether it is possible for the child view of this layout to scroll down. Override this if the child view is a custom view.
 * 判斷是否可以上拉
 */
public static boolean canChildScrollDown(View mChildView) {
    if (Build.VERSION.SDK_INT < 14) {
        if (mChildView instanceof AbsListView) {
            final AbsListView absListView = (AbsListView) mChildView;
            return absListView.getChildCount() > 0
                    && (absListView.getLastVisiblePosition() < absListView.getChildCount() - 1
                    || absListView.getChildAt(absListView.getChildCount() - 1).getBottom() > absListView.getPaddingBottom());
        } else {
            return ViewCompat.canScrollVertically(mChildView, 1) || mChildView.getScrollY() < 0;
        }
    } else {
        return ViewCompat.canScrollVertically(mChildView, 1);
    }
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:19,代碼來源:ScrollingUtil.java

示例14: isAbsListViewToBottom

import android.widget.AbsListView; //導入方法依賴的package包/類
public static boolean isAbsListViewToBottom(AbsListView absListView) {
    if (absListView != null && absListView.getAdapter() != null && absListView.getChildCount() > 0 && absListView.getLastVisiblePosition() == absListView.getAdapter().getCount() - 1) {
        View lastChild = absListView.getChildAt(absListView.getChildCount() - 1);

        return lastChild.getBottom() <= absListView.getMeasuredHeight();
    }
    return false;
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:9,代碼來源:ScrollingUtil.java

示例15: canScrollDown

import android.widget.AbsListView; //導入方法依賴的package包/類
public static boolean canScrollDown(View targetView) {
    if (android.os.Build.VERSION.SDK_INT < 14) {
        if (targetView instanceof AbsListView) {
            final AbsListView absListView = (AbsListView) targetView;
            return absListView.getChildCount() > 0
                    && (absListView.getLastVisiblePosition() < absListView.getChildCount() - 1
                    || absListView.getChildAt(absListView.getChildCount() - 1).getBottom() > absListView.getPaddingBottom());
        } else {
            return targetView.getScrollY() < 0;
        }
    } else {
        return targetView.canScrollVertically(1);
    }
}
 
開發者ID:scwang90,項目名稱:SmartRefreshLayout,代碼行數:15,代碼來源:ScrollBoundaryUtil.java


注:本文中的android.widget.AbsListView.getLastVisiblePosition方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。