当前位置: 首页>>代码示例>>Java>>正文


Java ViewPager.getCurrentItem方法代码示例

本文整理汇总了Java中android.support.v4.view.ViewPager.getCurrentItem方法的典型用法代码示例。如果您正苦于以下问题:Java ViewPager.getCurrentItem方法的具体用法?Java ViewPager.getCurrentItem怎么用?Java ViewPager.getCurrentItem使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.support.v4.view.ViewPager的用法示例。


在下文中一共展示了ViewPager.getCurrentItem方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: handleBackPress

import android.support.v4.view.ViewPager; //导入方法依赖的package包/类
/**
 * 将back事件分发给ViewPager中的Fragment,{@link #handleBackPress(FragmentManager)} 已经实现了对ViewPager的支持,所以自行决定是否使用该方法
 *
 * @return 如果处理了back键则返回 <b>true</b>
 * @see #handleBackPress(FragmentManager)
 * @see #handleBackPress(Fragment)
 * @see #handleBackPress(FragmentActivity)
 */
public static boolean handleBackPress(ViewPager viewPager) {
    if (viewPager == null) return false;
    PagerAdapter adapter = viewPager.getAdapter();
    if (adapter == null) return false;
    int currentItem = viewPager.getCurrentItem();
    Fragment fragment;
    if (adapter instanceof FragmentPagerAdapter) {
        fragment = ((FragmentPagerAdapter) adapter).getItem(currentItem);
    } else if (adapter instanceof FragmentStatePagerAdapter) {
        fragment = ((FragmentStatePagerAdapter) adapter).getItem(currentItem);
    } else {
        fragment = null;
    }
    return isFragmentBackHandled(fragment);
}
 
开发者ID:yangchong211,项目名称:YCUtils,代码行数:24,代码来源:BackHandlerHelper.java

示例2: setViewPagerCircle

import android.support.v4.view.ViewPager; //导入方法依赖的package包/类
/**
 * For circular adapter, where 2 fake page (first and last)
 */
public void setViewPagerCircle(ViewPager viewPager) {
  k = 1;
  viewPager.addOnPageChangeListener(this);
  max = viewPager.getAdapter().getCount();
  current = viewPager.getCurrentItem();
  if (current == 0) {
    current++;
    viewPager.setCurrentItem(current);
  }
  if (current == max) {
    current--;
    viewPager.setCurrentItem(current);
  }
  update();
}
 
开发者ID:AtlantPlatform,项目名称:atlant-android,代码行数:19,代码来源:IndicatorCircleView.java

示例3: setupWithViewPager

import android.support.v4.view.ViewPager; //导入方法依赖的package包/类
public void setupWithViewPager(ViewPager viewPager) {
PagerAdapter adapter = viewPager.getAdapter();
if (adapter == null) {
  throw new IllegalArgumentException("ViewPager does not have a PagerAdapter set");
} else {
  this.addTabsFromPagerAdapter(adapter);
  viewPager.setOnPageChangeListener(new TabLayout.TabLayoutOnPageChangeListener(this));
  this.setOnTabSelectedListener(new TabLayout.ViewPagerOnTabSelectedListener(viewPager));
  if (this.mSelectedTab == null || this.mSelectedTab.getPosition() != viewPager.getCurrentItem()) {
	this.getTabAt(viewPager.getCurrentItem()).select();
  }

}
 }
 
开发者ID:TIIEHenry,项目名称:TIIEHenry-Android-SDK,代码行数:15,代码来源:TabLayout.java

示例4: isReadyForPullStart

import android.support.v4.view.ViewPager; //导入方法依赖的package包/类
@Override
protected boolean isReadyForPullStart() {
	ViewPager refreshableView = getRefreshableView();

	PagerAdapter adapter = refreshableView.getAdapter();
	if (null != adapter) {
		return refreshableView.getCurrentItem() == 0;
	}

	return false;
}
 
开发者ID:SavorGit,项目名称:Hotspot-master-devp,代码行数:12,代码来源:PullToRefreshViewPager.java

示例5: isReadyForPullEnd

import android.support.v4.view.ViewPager; //导入方法依赖的package包/类
@Override
protected boolean isReadyForPullEnd() {
	ViewPager refreshableView = getRefreshableView();

	PagerAdapter adapter = refreshableView.getAdapter();
	if (null != adapter) {
		return refreshableView.getCurrentItem() == adapter.getCount() - 1;
	}

	return false;
}
 
开发者ID:SavorGit,项目名称:Hotspot-master-devp,代码行数:12,代码来源:PullToRefreshViewPager.java

示例6: 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

示例7: onInterceptTouchEvent

import android.support.v4.view.ViewPager; //导入方法依赖的package包/类
/**
 * 事件拦截操作
 */
@Override
public boolean onInterceptTouchEvent(MotionEvent ev) {
    //处理ViewPager冲突问题
    ViewPager mViewPager = getTouchViewPager(mViewPagers, ev);
    if (mViewPager != null && mViewPager.getCurrentItem() != 0) {
        return super.onInterceptTouchEvent(ev);
    }
    switch (ev.getAction()) {
        case MotionEvent.ACTION_DOWN:
            downX = tempX = (int) ev.getRawX();
            downY = (int) ev.getRawY();
            canSwipe = downX <= viewWidth / 2;
            if (!canSwipe) {
                return super.onInterceptTouchEvent(ev);
            }
            break;
        case MotionEvent.ACTION_MOVE:
            if (!canSwipe) {
                return super.onInterceptTouchEvent(ev);
            }
            int moveX = (int) ev.getRawX();
            // 满足此条件屏蔽SildingFinishLayout里面子类的touch事件
            if (moveX - downX > mTouchStop && Math.abs((int) ev.getRawY() - downY) < mTouchStop) {
                return true;
            }
            break;
    }

    return super.onInterceptTouchEvent(ev);
}
 
开发者ID:haihaio,项目名称:AmenEye,代码行数:34,代码来源:SwipeBackLayout.java

示例8: displayNextFragment

import android.support.v4.view.ViewPager; //导入方法依赖的package包/类
private void displayNextFragment() {
  ViewPager vp = (ViewPager) getActivity().findViewById(R.id.container);
  int currentItem = vp.getCurrentItem();
  if (currentItem < vp.getAdapter().getCount()) {
    vp.setCurrentItem(currentItem + 1);
  }
}
 
开发者ID:Komdosh,项目名称:SocEltech,代码行数:8,代码来源:TestViewFragment.java

示例9: setViewPager

import android.support.v4.view.ViewPager; //导入方法依赖的package包/类
public void setViewPager(ViewPager viewPager) {
  k = 0;
  viewPager.addOnPageChangeListener(this);
  max = viewPager.getAdapter().getCount();
  current = viewPager.getCurrentItem();
  update();
}
 
开发者ID:AtlantPlatform,项目名称:atlant-android,代码行数:8,代码来源:IndicatorCircleView.java

示例10: canViewPagerScrollHorizontally

import android.support.v4.view.ViewPager; //导入方法依赖的package包/类
boolean canViewPagerScrollHorizontally(ViewPager p, int dx) {
    return !(dx < 0 && p.getCurrentItem() <= 0 ||
            0 < dx && p.getAdapter().getCount() - 1 <= p.getCurrentItem());
}
 
开发者ID:chemickypes,项目名称:Glitchy,代码行数:5,代码来源:SideMenu.java


注:本文中的android.support.v4.view.ViewPager.getCurrentItem方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。