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


Java ViewPager.getContext方法代码示例

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


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

示例1: bind

import android.support.v4.view.ViewPager; //导入方法依赖的package包/类
@BindingAdapter(value = {"fragments", "curIndex"}, requireAll = false)
public static void bind(ViewPager container, final List<? extends Fragment> fragments, int curIndex) {
    if(!(container.getContext() instanceof FragmentActivity))
        throw new IllegalArgumentException(TAG + "context must instanceof FragmentActivity");
    FragmentManager fm = ((FragmentActivity) container.getContext()).getSupportFragmentManager();

    if (fragments != null && !fragments.isEmpty()) {
        PagerAdapter adapter = container.getAdapter();
        if(adapter == null) {
            // initialize, fragments are only added once !!!
            container.setAdapter(adapter = new FragmentPagerAdapter(fm) {
                @Override
                public Fragment getItem(int position) {
                    return fragments.get(position);
                }

                @Override
                public int getCount() {
                    return fragments.size();
                }
            });
        }

        adapter.notifyDataSetChanged();

        if(curIndex >= 0 && curIndex < fragments.size())
            container.setCurrentItem(curIndex);
    }
}
 
开发者ID:fashare2015,项目名称:MVVM-JueJin,代码行数:30,代码来源:FragmentAdapter.java

示例2: setDuration

import android.support.v4.view.ViewPager; //导入方法依赖的package包/类
private static void setDuration(ViewPager pager, int duration) {
    try {
        FixedSpeedScroller scroller = new FixedSpeedScroller(pager.getContext(), new AccelerateDecelerateInterpolator(), duration);
        Field field = ViewPager.class.getDeclaredField("mScroller");
        field.setAccessible(true);
        field.set(pager, scroller);
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
开发者ID:czy1121,项目名称:bannerview,代码行数:11,代码来源:BannerView.java

示例3: ViewPageFragmentAdapter

import android.support.v4.view.ViewPager; //导入方法依赖的package包/类
public ViewPageFragmentAdapter(FragmentManager fm,
                               PagerSlidingTabStrip pageStrip, ViewPager pager) {
    super(fm);
    mContext = pager.getContext();
    mPagerStrip = pageStrip;
    mViewPager = pager;
    mViewPager.setAdapter(this);
    mPagerStrip.setViewPager(mViewPager);
}
 
开发者ID:hsj-xiaokang,项目名称:OSchina_resources_android,代码行数:10,代码来源:ViewPageFragmentAdapter.java

示例4: changeViewPagerScroller

import android.support.v4.view.ViewPager; //导入方法依赖的package包/类
/**
 * 通过反射改变banner的切换速度
 */
private void changeViewPagerScroller(ViewPager mViewPager) {
    try {
        Field mField = ViewPager.class.getDeclaredField("mScroller");
        mField.setAccessible(true);
        //用自定义的类替换mScroller
        FixedSpeedScroller fixedSpeedScroller = new FixedSpeedScroller(mViewPager.getContext(), new AccelerateInterpolator(), 600);
        mField.set(mViewPager, fixedSpeedScroller);
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
开发者ID:shenhuanet,项目名称:OpenEyesReading-android,代码行数:15,代码来源:BannerView.java

示例5: ActionsPagerAdapter

import android.support.v4.view.ViewPager; //导入方法依赖的package包/类
public ActionsPagerAdapter(ViewPager viewPager, List<BaseAction> actions) {
    this.context = viewPager.getContext();
    this.actions = new ArrayList<>(actions);
    this.viewPager = viewPager;
    this.gridViewCount = (actions.size() + ITEM_COUNT_PER_GRID_VIEW - 1) / ITEM_COUNT_PER_GRID_VIEW;
}
 
开发者ID:newDeepLearing,项目名称:decoy,代码行数:7,代码来源:ActionsPagerAdapter.java


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