當前位置: 首頁>>代碼示例>>Java>>正文


Java ViewPager.getAdapter方法代碼示例

本文整理匯總了Java中android.support.v4.view.ViewPager.getAdapter方法的典型用法代碼示例。如果您正苦於以下問題:Java ViewPager.getAdapter方法的具體用法?Java ViewPager.getAdapter怎麽用?Java ViewPager.getAdapter使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.support.v4.view.ViewPager的用法示例。


在下文中一共展示了ViewPager.getAdapter方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: setViewPager

import android.support.v4.view.ViewPager; //導入方法依賴的package包/類
/** 關聯ViewPager,用於不想在ViewPager適配器中設置titles數據的情況 */
public void setViewPager(ViewPager vp, String[] titles) {
    if (vp == null || vp.getAdapter() == null) {
        throw new IllegalStateException("ViewPager or ViewPager adapter can not be NULL !");
    }

    if (titles == null || titles.length == 0) {
        throw new IllegalStateException("Titles can not be EMPTY !");
    }

    if (titles.length != vp.getAdapter().getCount()) {
        throw new IllegalStateException("Titles length must be the same as the page count !");
    }

    this.mViewPager = vp;
    mTitles = new ArrayList<>();
    Collections.addAll(mTitles, titles);

    this.mViewPager.removeOnPageChangeListener(this);
    this.mViewPager.addOnPageChangeListener(this);
    notifyDataSetChanged();
}
 
開發者ID:LonelyMushroom,項目名稱:aarLibrary,代碼行數:23,代碼來源:SlidingTabLayout.java

示例2: setViewPager

import android.support.v4.view.ViewPager; //導入方法依賴的package包/類
/**
 * Set the {@link ViewPager} associated with this widget indicator.
 *
 * @param pager     {@link ViewPager} to attach
 * @param stepCount The real page count to display (use this if you are using looped viewpager to indicate the real number
 *                  of pages)
 */
public void setViewPager(ViewPager pager, int stepCount) {
    if (this.pager == pager) {
        return;
    }
    if (this.pager != null) {
        pager.removeOnPageChangeListener(this);
    }
    if (pager.getAdapter() == null) {
        throw new IllegalStateException("ViewPager does not have adapter instance.");
    }

    this.pager = pager;
    this.stepCount = stepCount;
    currentStep = 0;
    pager.addOnPageChangeListener(this);

    if(showLabels && labels == null) {
        setLabelsUsingPageTitles();
    }

    invalidate();
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:30,代碼來源:StepperIndicator.java

示例3: setViewPager

import android.support.v4.view.ViewPager; //導入方法依賴的package包/類
@Override
public void setViewPager(ViewPager view) {
    if (mViewPager == view) {
        return;
    }
    if (mViewPager != null) {
        mViewPager.setOnPageChangeListener(null);
    }
    final PagerAdapter adapter = view.getAdapter();
    if (adapter == null) {
        throw new IllegalStateException("ViewPager does not have adapter instance.");
    }
    mViewPager = view;
    view.setOnPageChangeListener(this);
    notifyDataSetChanged();
}
 
開發者ID:fikyair,項目名稱:musicplayer,代碼行數:17,代碼來源:TabPageIndicator.java

示例4: setViewPager

import android.support.v4.view.ViewPager; //導入方法依賴的package包/類
@Override
public void setViewPager(ViewPager view) {
    if (mViewPager == view) {
        return;
    }
    if (mViewPager != null) {
        mViewPager.setOnPageChangeListener(null);
    }
    PagerAdapter adapter = view.getAdapter();
    if (adapter == null) {
        throw new IllegalStateException("ViewPager does not have adapter instance.");
    }
    mViewPager = view;
    view.setOnPageChangeListener(this);
    notifyDataSetChanged();
}
 
開發者ID:benniaobuguai,項目名稱:android-project-gallery,代碼行數:17,代碼來源:IconPageIndicator.java

示例5: setViewPager

import android.support.v4.view.ViewPager; //導入方法依賴的package包/類
@Override
public void setViewPager(ViewPager viewPager) {
    if (mViewPager == viewPager) {
        return;
    }
    if (mViewPager != null) {
        //Clear us from the old pager.
        mViewPager.setOnPageChangeListener(null);
    }
    if (viewPager.getAdapter() == null) {
        throw new IllegalStateException("ViewPager does not have adapter instance.");
    }
    mViewPager = viewPager;
    mViewPager.setOnPageChangeListener(this);
    invalidate();
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:17,代碼來源:LinePageIndicator.java

示例6: setViewPager

import android.support.v4.view.ViewPager; //導入方法依賴的package包/類
/**
 * 關聯ViewPager,用於不想在ViewPager適配器中設置titles數據的情況
 */
public void setViewPager(ViewPager vp, String[] titles) {
    if (vp == null || vp.getAdapter() == null) {
        throw new IllegalStateException("ViewPager or ViewPager adapter can not be NULL !");
    }

    if (titles == null || titles.length == 0) {
        throw new IllegalStateException("Titles can not be EMPTY !");
    }

    if (titles.length != vp.getAdapter().getCount()) {
        throw new IllegalStateException("Titles length must be the same as the page count !");
    }

    this.mViewPager = vp;
    mTitles = new ArrayList<>();
    Collections.addAll(mTitles, titles);

    this.mViewPager.removeOnPageChangeListener(this);
    this.mViewPager.addOnPageChangeListener(this);
    notifyDataSetChanged();
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:25,代碼來源:SlidingTabLayout.java

示例7: setViewPager

import android.support.v4.view.ViewPager; //導入方法依賴的package包/類
@Override
public void setViewPager(ViewPager viewPager) {
    if (mViewPager == viewPager) {
        return;
    }
    if (mViewPager != null) {
        //Clear us from the old pager.
        mViewPager.setOnPageChangeListener(null);
    }
    if (viewPager.getAdapter() == null) {
        throw new IllegalStateException("ViewPager does not have adapter instance.");
    }
    mViewPager = viewPager;
    mViewPager.setOnPageChangeListener(this);
    invalidate();
    post(new Runnable() {
        @Override public void run() {
            if (mFades) {
                post(mFadeRunnable);
            }
        }
    });
}
 
開發者ID:Dnet3,項目名稱:CustomAndroidOneSheeld,代碼行數:24,代碼來源:UnderlinePageIndicator.java

示例8: bind

import android.support.v4.view.ViewPager; //導入方法依賴的package包/類
private static void bind(ViewPager container, final ItemView itemView, final List<?> datas, final OnItemClickListener<?> onItemClickListener) {
    PagerAdapter adapter;
    if (datas != null && !datas.isEmpty()) {
        adapter = container.getAdapter();
        if(adapter == null) {
            // initialize, adapter is only set once !!!
            container.setAdapter(adapter = new CommonPagerAdapter<Object>(container.getContext(), itemView.layoutRes(), (List<Object>)datas) {
                @Override
                protected void convert(ViewHolder holder, Object data, int position) {
                    DataBindingUtil.bind(holder.itemView).setVariable(itemView.bindingVariable(), data);
                }
            });

            ((CommonPagerAdapter<Object>)adapter).setOnItemClickListener((OnItemClickListener<Object>)onItemClickListener);
        }

        adapter.notifyDataSetChanged();
    }
}
 
開發者ID:fashare2015,項目名稱:MVVM-JueJin,代碼行數:20,代碼來源:ViewPagerAdapter.java

示例9: setViewPager

import android.support.v4.view.ViewPager; //導入方法依賴的package包/類
/** 關聯ViewPager */
public void setViewPager(ViewPager vp) {
    if (vp == null || vp.getAdapter() == null) {
        throw new IllegalStateException("ViewPager or ViewPager adapter can not be NULL !");
    }

    this.mViewPager = vp;

    this.mViewPager.removeOnPageChangeListener(this);
    this.mViewPager.addOnPageChangeListener(this);
    notifyDataSetChanged();
}
 
開發者ID:devzwy,項目名稱:NeiHanDuanZiTV,代碼行數:13,代碼來源:SlidingTabLayout.java

示例10: setViewPager

import android.support.v4.view.ViewPager; //導入方法依賴的package包/類
public void setViewPager(ViewPager view) {
    if (this.mViewPager != view) {
        if (this.mViewPager != null) {
            this.mViewPager.setOnPageChangeListener(null);
        }
        if (view.getAdapter() == null) {
            throw new IllegalStateException("ViewPager does not have adapter instance.");
        }
        this.mViewPager = view;
        view.setOnPageChangeListener(this);
        notifyDataSetChanged();
    }
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:14,代碼來源:IconPageIndicator.java

示例11: setViewPager

import android.support.v4.view.ViewPager; //導入方法依賴的package包/類
@Override
public void setViewPager(ViewPager view) {
    if (mViewPager == view) {
        return;
    }
    if (mViewPager != null) {
        mViewPager.setOnPageChangeListener(null);
    }
    if (view.getAdapter() == null) {
        throw new IllegalStateException("ViewPager does not have adapter instance.");
    }
    mViewPager = view;
    mViewPager.setOnPageChangeListener(this);
    invalidate();
}
 
開發者ID:SShineTeam,項目名稱:Huochexing12306,代碼行數:16,代碼來源:TitlePageIndicator.java

示例12: setViewPager

import android.support.v4.view.ViewPager; //導入方法依賴的package包/類
public void setViewPager(ViewPager pager) {
  this.pager = pager;

  if (pager.getAdapter() == null) {
    throw new IllegalStateException("ViewPager does not have adapter instance.");
  }

  pager.setOnPageChangeListener(pageListener);

  notifyDataSetChanged();
  fadeTekstOgIkoner(pager.getCurrentItem());
}
 
開發者ID:nordfalk,項目名稱:EsperantoRadio,代碼行數:13,代碼來源:PagerSlidingTabStrip.java

示例13: setViewPager

import android.support.v4.view.ViewPager; //導入方法依賴的package包/類
public void setViewPager(ViewPager pager) {
    this.pager = pager;

    if (pager.getAdapter() == null) {
        throw new IllegalStateException("ViewPager does not have adapter instance.");
    }

    notifyDataSetChanged();
}
 
開發者ID:newDeepLearing,項目名稱:decoy,代碼行數:10,代碼來源:PagerSlidingTabStrip.java

示例14: setViewPager

import android.support.v4.view.ViewPager; //導入方法依賴的package包/類
public void setViewPager(ViewPager pager) {
    this.pager = pager;

    if (pager.getAdapter() == null) {
        throw new IllegalStateException(
                "ViewPager does not have adapter instance.");
    }

    pager.setOnPageChangeListener(pageListener);

    notifyDataSetChanged();
}
 
開發者ID:89luca89,項目名稱:ThunderMusic,代碼行數:13,代碼來源:PagerTabStrip.java

示例15: createIndicators

import android.support.v4.view.ViewPager; //導入方法依賴的package包/類
private void createIndicators(ViewPager viewPager) {
    removeAllViews();
    if (viewPager.getAdapter() == null) {
        return;
    }

    int count = viewPager.getAdapter().getCount();
    if (count <= 0) {
        return;
    }
    addIndicator(mIndicatorBackgroundResId, mAnimationOut);
    for (int i = 1; i < count; i++) {
        addIndicator(mIndicatorUnselectedBackgroundResId, mAnimationIn);
    }
}
 
開發者ID:SkylineLabs,項目名稱:FindX,代碼行數:16,代碼來源:CircleIndicator.java


注:本文中的android.support.v4.view.ViewPager.getAdapter方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。