本文整理汇总了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();
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}
示例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);
}
}
});
}
示例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();
}
}
示例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();
}
示例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();
}
}
示例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();
}
示例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());
}
示例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();
}
示例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();
}
示例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);
}
}