當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。