当前位置: 首页>>代码示例>>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;未经允许,请勿转载。