本文整理汇总了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);
}
示例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;
}
示例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;
}