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


Java PagerAdapter.getCount方法代码示例

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


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

示例1: onPageScrolled

import android.support.v4.view.PagerAdapter; //导入方法依赖的package包/类
@Override
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
    // The documentation says that `getPageWidth(...)` returns the fraction of the _measured_ width that that page takes up.  However, the code seems to
    // use the width so we will here too.
    final int width = getWidth();
    PagerAdapter adapter = RtlViewPager.super.getAdapter();
    if (isRtl() && adapter != null) {
        int count = adapter.getCount();
        int remainingWidth = (int) (width * (1 - adapter.getPageWidth(position))) + positionOffsetPixels;
        while (position < count && remainingWidth > 0) {
            position += 1;
            remainingWidth -= (int) (width * adapter.getPageWidth(position));
        }
        position = count - position - 1;
        positionOffsetPixels = -remainingWidth;
        positionOffset = positionOffsetPixels / (width * adapter.getPageWidth(position));
    }
    mListener.onPageScrolled(position, positionOffset, positionOffsetPixels);
}
 
开发者ID:fekracomputers,项目名称:IslamicLibraryAndroid,代码行数:20,代码来源:RtlViewPager.java

示例2: scrollOnce

import android.support.v4.view.PagerAdapter; //导入方法依赖的package包/类
/**
 * scroll only once
 */
public void scrollOnce() {
    PagerAdapter adapter = getAdapter();
    int currentItem = getCurrentItem();
    int totalCount;
    if (adapter == null || (totalCount = adapter.getCount()) <= 1) {
        return;
    }

    int nextItem = (direction == LEFT) ? --currentItem : ++currentItem;
    if (nextItem < 0) {
        if (isCycle) {
            setCurrentItem(totalCount - 1, isBorderAnimation);
        }
    } else if (nextItem == totalCount) {
        if (isCycle) {
            setCurrentItem(0, isBorderAnimation);
        }
    } else {
        setCurrentItem(nextItem, true);
    }
}
 
开发者ID:tranleduy2000,项目名称:text_converter,代码行数:25,代码来源:AutoScrollViewPager.java

示例3: notifyDataSetChanged

import android.support.v4.view.PagerAdapter; //导入方法依赖的package包/类
public void notifyDataSetChanged() {
    mTabLayout.removeAllViews();
    PagerAdapter adapter = mViewPager.getAdapter();
    IconPagerAdapter iconAdapter = null;
    if (adapter instanceof IconPagerAdapter) {
        iconAdapter = (IconPagerAdapter)adapter;
    }
    final int count = adapter.getCount();
    for (int i = 0; i < count; i++) {
        CharSequence title = adapter.getPageTitle(i);
        if (title == null) {
            title = EMPTY_TITLE;
        }
        int iconResId = 0;
        if (iconAdapter != null) {
            iconResId = iconAdapter.getIconResId(i);
        }
        addTab(i, title, iconResId);
    }
    if (mSelectedTabIndex > count) {
        mSelectedTabIndex = count - 1;
    }
    setCurrentItem(mSelectedTabIndex);
    requestLayout();
}
 
开发者ID:SShineTeam,项目名称:Huochexing12306,代码行数:26,代码来源:TabPageIndicator.java

示例4: notifyDataSetChanged

import android.support.v4.view.PagerAdapter; //导入方法依赖的package包/类
public void notifyDataSetChanged() {
    this.mTabLayout.removeAllViews();
    PagerAdapter adapter = this.mViewPager.getAdapter();
    IconPagerAdapter iconAdapter = null;
    if (adapter instanceof IconPagerAdapter) {
        iconAdapter = (IconPagerAdapter) adapter;
    }
    int count = adapter.getCount();
    for (int i = 0; i < count; i++) {
        CharSequence title = adapter.getPageTitle(i);
        if (title == null) {
            title = EMPTY_TITLE;
        }
        int iconResId = 0;
        if (iconAdapter != null) {
            iconResId = iconAdapter.getIconResId(i);
        }
        addTab(i, title, iconResId);
    }
    if (this.mSelectedTabIndex > count) {
        this.mSelectedTabIndex = count - 1;
    }
    setCurrentItem(this.mSelectedTabIndex);
    requestLayout();
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:26,代码来源:TabPageIndicator.java

示例5: setAdapter

import android.support.v4.view.PagerAdapter; //导入方法依赖的package包/类
@Override
public void setAdapter(PagerAdapter adapter) {
    wrappedPagerAdapter = adapter;
    //若设置的 adapter 不为空则对其进行包装
    wrapperPagerAdapter = (wrappedPagerAdapter == null) ? null : new AutoScrollPagerAdapter(adapter);
    super.setAdapter(wrapperPagerAdapter);  //为viewPager设置的是包装的adapter
    if (adapter != null && adapter.getCount() != 0) {
        post(new Runnable() {
            @Override
            public void run() {
                setCurrentItem(0, false);
            }
        });
    }
    startAutoScroll();
}
 
开发者ID:haihaio,项目名称:AmenEye,代码行数:17,代码来源:AutoScrollViewPager.java

示例6: notifyDataSetChanged

import android.support.v4.view.PagerAdapter; //导入方法依赖的package包/类
public void notifyDataSetChanged() {
    PagerAdapter adapter = this.mViewPager.getAdapter();
    int count = adapter.getCount();
    if (count != 0) {
        int width = TAB_MARGIN;
        for (int i = 0; i < count; i++) {
            width += getTabWidth(adapter.getPageTitle(i)) + TAB_MARGIN;
        }
        this.mMeanWidth = -1;
        if (this.mLayoutWidh > width && count <= 7) {
            this.mMeanWidth = (this.mLayoutWidh - (TAB_MARGIN * (count + 1))) / count;
        }
        super.notifyDataSetChanged();
    }
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:16,代码来源:ChannelTabPageIndicator.java

示例7: notifyDataSetChanged

import android.support.v4.view.PagerAdapter; //导入方法依赖的package包/类
public void notifyDataSetChanged() {
    PagerAdapter adapter = this.mViewPager.getAdapter();
    int count = adapter.getCount();
    if (count != 0) {
        int width = TAB_MARGIN;
        for (int i = 0; i < count; i++) {
            width += getTabWidth(adapter.getPageTitle(i)) + TAB_MARGIN;
        }
        this.mMeanWidth = -1;
        if (this.mLayoutWidth > width && count <= 7) {
            this.mMeanWidth = this.mLayoutWidth / count;
        }
        super.notifyDataSetChanged();
    }
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:16,代码来源:HotTabPageIndicator.java

示例8: setAdapter

import android.support.v4.view.PagerAdapter; //导入方法依赖的package包/类
public PagerAdapter setAdapter(final PagerAdapter adapter) {
    // If adapter count bigger then 2 need to set InfiniteCyclePagerAdapter
    if (adapter != null && adapter.getCount() >= MIN_CYCLE_COUNT) {
        mItemCount = adapter.getCount();
        mInfiniteCyclePagerAdapter = new InfiniteCyclePagerAdapter(adapter);
        mInfiniteCyclePagerAdapter.setOnNotifyDataSetChangedListener(this);
        return mInfiniteCyclePagerAdapter;
    } else {
        if (mInfiniteCyclePagerAdapter != null) {
            mInfiniteCyclePagerAdapter.setOnNotifyDataSetChangedListener(null);
            mInfiniteCyclePagerAdapter = null;
        }
        return adapter;
    }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:16,代码来源:InfiniteCycleManager.java

示例9: populateTabStrip

import android.support.v4.view.PagerAdapter; //导入方法依赖的package包/类
private void populateTabStrip() {
  final PagerAdapter adapter = viewPager.getAdapter();

  for (int i = 0; i < adapter.getCount(); i++) {

    final View tabView = (tabProvider == null)
        ? createDefaultTabView(adapter.getPageTitle(i))
        : tabProvider.createTabView(tabStrip, i, adapter);

    if (tabView == null) {
      throw new IllegalStateException("tabView is null.");
    }

    if (distributeEvenly) {
      LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) tabView.getLayoutParams();
      lp.width = 0;
      lp.weight = 1;
    }

    if (internalTabClickListener != null) {
      tabView.setOnClickListener(internalTabClickListener);
    }

    tabStrip.addView(tabView);

    if (i == viewPager.getCurrentItem()) {
      tabView.setSelected(true);
    }

  }
}
 
开发者ID:huashengzzz,项目名称:SmartChart,代码行数:32,代码来源:SmartTabLayout.java

示例10: notifyDataSetChanged

import android.support.v4.view.PagerAdapter; //导入方法依赖的package包/类
public void notifyDataSetChanged() {
    selectedPosition = 0;
    titles.clear();
    PagerAdapter adapter = mViewPager.getAdapter();
    final int count = adapter.getCount();
    for (int i = 0; i < count; i++) {
        titles.add(adapter.getPageTitle(i).toString());
    }
    invalidate();
}
 
开发者ID:li-yu,项目名称:FakeWeather,代码行数:11,代码来源:SimplePagerIndicator.java

示例11: isScrolledAtEnd

import android.support.v4.view.PagerAdapter; //导入方法依赖的package包/类
/**
 */
@Override
public boolean isScrolledAtEnd() {
	if (mScrollableView.getChildCount() == 0) {
		return true;
	}
	final PagerAdapter adapter = mScrollableView.getAdapter();
	return adapter == null || adapter.getCount() == 0 || mScrollableView.getCurrentItem() == (adapter.getCount() - 1);
}
 
开发者ID:universum-studios,项目名称:android_ui,代码行数:11,代码来源:ScrollableWrapper.java

示例12: onViewPagerCreated

import android.support.v4.view.PagerAdapter; //导入方法依赖的package包/类
@Override
public void onViewPagerCreated() {
    PagerAdapter adapter = vViewPager.getAdapter();
    if (adapter == null)
        return;
    if (!setCurrentDay) {
        int idx = getTimetable().getDayIndexIn(0);
        if (idx != -1 && adapter.getCount() != 0) {
            vViewPager.setCurrentItem(idx);
            setCurrentDay = true;
        }
    }
}
 
开发者ID:gregoreesmaa,项目名称:minu-poska-android,代码行数:14,代码来源:MyScheduleActivity.java

示例13: getCurrentItem

import android.support.v4.view.PagerAdapter; //导入方法依赖的package包/类
@Override
public int getCurrentItem() {
    int item = super.getCurrentItem();
    PagerAdapter adapter = super.getAdapter();
    if (adapter != null && isRtl()) {
        item = adapter.getCount() - item - 1;
    }
    return item;
}
 
开发者ID:fekracomputers,项目名称:IslamicLibraryAndroid,代码行数:10,代码来源:RtlViewPager.java

示例14: setCurrentItem

import android.support.v4.view.PagerAdapter; //导入方法依赖的package包/类
@Override
public void setCurrentItem(int position, boolean smoothScroll) {
    PagerAdapter adapter = super.getAdapter();
    if (adapter != null && isRtl()) {
        position = adapter.getCount() - position - 1;
    }
    super.setCurrentItem(position, smoothScroll);
}
 
开发者ID:fekracomputers,项目名称:IslamicLibraryAndroid,代码行数:9,代码来源:RtlViewPager.java

示例15: notifyDataSetChanged

import android.support.v4.view.PagerAdapter; //导入方法依赖的package包/类
public void notifyDataSetChanged() {

    tabsContainer.removeAllViews();
    PagerAdapter adapter = pager.getAdapter();

    tabCount = adapter.getCount();

    for (int i = 0; i < tabCount; i++) {

      if (adapter instanceof IconTabProvider) {
        IconTabProvider ipa = ((IconTabProvider) adapter);
        if (TEKST_DER_FADER_OVER_I_IKONER) {
          int resId = ipa.getPageIconResId(i);
          if (resId!=0) addIconTabBådeTekstOgBillede(i, resId, null, ipa.getPageContentDescription(i));
          else {
            String url = ipa.getPageIconUrl(i);
            if (url!=null) addIconTabBådeTekstOgBillede(i, resId, url, ipa.getPageContentDescription(i));
            else addTextTab(i, adapter.getPageTitle(i).toString());
          }
        } else {
          addIconTab(i, ipa.getPageIconResId(i), ipa.getPageContentDescription(i));
        }
      } else {
        addTextTab(i, adapter.getPageTitle(i).toString());
      }

    }

    updateTabStyles();

    getViewTreeObserver().addOnGlobalLayoutListener(new OnGlobalLayoutListener() {

      @SuppressWarnings("deprecation")
      @SuppressLint("NewApi")
      @Override
      public void onGlobalLayout() {

        if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) {
          getViewTreeObserver().removeGlobalOnLayoutListener(this);
        } else {
          getViewTreeObserver().removeOnGlobalLayoutListener(this);
        }

        currentPosition = pager.getCurrentItem();
        scrollToChild(currentPosition, 0);
      }
    });
    if (TEKST_DER_FADER_OVER_I_IKONER) {
      fadeTekstOgIkoner(currentPosition);
    }
  }
 
开发者ID:nordfalk,项目名称:EsperantoRadio,代码行数:52,代码来源:PagerSlidingTabStrip.java


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