本文整理匯總了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;
}