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


Java ViewPager.getChildCount方法代碼示例

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


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

示例1: onCreate

import android.support.v4.view.ViewPager; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);

  setContentView(R.layout.activity_main);

  ViewPager pager = (ViewPager) findViewById(R.id.pager);
  mAdapter = new MyPagerAdapter(pager.getChildCount());

  pager.setAdapter(mAdapter);
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:12,代碼來源:MainActivity.java

示例2: getCurrentView

import android.support.v4.view.ViewPager; //導入方法依賴的package包/類
public View getCurrentView(ViewPager pager) {
    for (int i = 0; i < pager.getChildCount(); i++) {
        if ((int) pager.getChildAt(i).getTag(R.id.index) == pager.getCurrentItem()) {
            return pager.getChildAt(i);
        }
    }

    return null;
}
 
開發者ID:adithya321,項目名稱:Instincts-2k17,代碼行數:10,代碼來源:GalleryViewPagerAdapter.java

示例3: clampViewPositionVertical

import android.support.v4.view.ViewPager; //導入方法依賴的package包/類
/***
 * clampViewPositionHorizontal()之後調用
 */
@Override
public int clampViewPositionVertical(final View child, final int top, final int dy) {
    if (mScrollChild instanceof ViewPager) {
        final ViewPager pager = (ViewPager) mScrollChild;
        mScrollChild = pager.getChildAt(pager.getCurrentItem());
        final int cacheCount = pager.getChildCount();
        int[] points = new int[2];
        for (int i = 0; i < cacheCount; i++) {
            View view = pager.getChildAt(i);
            view.getLocationInWindow(points);
            if (mTouchX >= points[0] && mTouchX < points[0] + view.getWidth()) {
                mScrollChild = view;
                break;
            }

        }
    }
    int topBounds;
    int bottomBounds;
    if (isAllowDragDirection(UP)
            && !childCanScrollDown()
            && top >= mOriginalY
            && mCurDragDirection == UP) {
        topBounds = getPaddingTop();
        bottomBounds = mVerticalDragRange;
        if (null != mOnSwipeBackCallback
                && mOnSwipeBackCallback.onIntercept(mCurDragDirection, mTouchX, mTouchY)
                && mCurDragDirection != NONE
                ) {
            mCurDragDirection = NONE;
            return mOriginalY;
        }
        return Math.min(Math.max(top, topBounds), bottomBounds);
    }
    if (isAllowDragDirection(DOWN)
            && !childCanScrollUp()
            && top <= mOriginalY
            && mCurDragDirection == DOWN) {
        topBounds = -mVerticalDragRange;
        bottomBounds = getPaddingTop();
        if (null != mOnSwipeBackCallback
                && mOnSwipeBackCallback.onIntercept(mCurDragDirection, mTouchX, mTouchY)
                && mCurDragDirection != NONE
                ) {
            mCurDragDirection = NONE;
            return mOriginalY;
        }
        return Math.min(Math.max(top, topBounds), bottomBounds);
    }
    return mOriginalY;
}
 
開發者ID:zhouphenix,項目名稱:Multi-SwipeBackLayout,代碼行數:55,代碼來源:SwipeBackLayout.java


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