当前位置: 首页>>代码示例>>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;未经允许,请勿转载。