List of usage examples for android.support.v4.view PagerAdapter getPageTitle
public CharSequence getPageTitle(int position)
From source file:com.example.anumbrella.viewpager.TabPagerIndicator.java
@Override public void notifyDataSetChanged() { mTabLayout.removeAllViews();/*from w w w. j a va 2 s. c o m*/ PagerAdapter adapter = mViewPager.getAdapter(); //tabs? 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; } //tabs?id int iconResId = 0; if (iconAdapter != null) { iconResId = iconAdapter.getIconResId(i); } addTab(title, i, iconResId); } if (mSelectedTabIndex > count) { mSelectedTabIndex = count - 1; } setCurrentItem(mSelectedTabIndex); requestLayout(); }
From source file:com.malus.pushshow.widget.TabPageIndicator.java
public void notifyDataSetChanged() { mTabLayout.removeAllViews();//w ww.j a v a2 s . com PagerAdapter adapter = mViewPager.getAdapter(); IconPagerAdapter iconAdapter = null; if (adapter instanceof IconPagerAdapter) { iconAdapter = (IconPagerAdapter) adapter; } final int count = adapter.getCount(); ViewPagerCount = count; 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(); }
From source file:com.common.widget.pageindicator.C_TabPageIndicator.java
@Override public void notifyDataSetChanged() { mTabLayout.removeAllViews();//from w w w .j a va 2s . c o m PagerAdapter adapter = mViewPager.getAdapter(); C_IconPagerAdapter iconAdapter = null; if (adapter instanceof C_IconPagerAdapter) { iconAdapter = (C_IconPagerAdapter) adapter; } final int count = adapter.getCount(); lastTabIndex = count - 1; 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(); }
From source file:com.viewpagerindicator.NewTabPageIndicator.java
public void notifyDataSetChanged(boolean[] isNew) { mTabLayout.removeAllViews();//from www . j a v a2s . co m 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; int backgroundResId = 0; int textSize = 0; int textColor = 0; if (iconAdapter != null) { iconResId = iconAdapter.getIconResId(i); backgroundResId = iconAdapter.getBackgroundResId(i); textSize = iconAdapter.getTextSize(); textColor = iconAdapter.getTextColor(); } addTab(i, title, iconResId, backgroundResId, textSize, textColor, isNew[i]); } if (mSelectedTabIndex > count) { mSelectedTabIndex = count - 1; } setCurrentItem(mSelectedTabIndex); requestLayout(); }
From source file:com.viewpagerindicator.NewTabPageIndicator.java
public void notifyDataSetChanged() { mTabLayout.removeAllViews();//from ww w.ja v a2 s . c om 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; int backgroundResId = 0; int textSize = 0; int textColor = 0; if (iconAdapter != null) { iconResId = iconAdapter.getIconResId(i); backgroundResId = iconAdapter.getBackgroundResId(i); textSize = iconAdapter.getTextSize(); textColor = iconAdapter.getTextColor(); } if (count < 5) { addTab(i, title, iconResId, backgroundResId, textSize, textColor, false); } else { addTab(i, title, iconResId, backgroundResId, textSize, textColor); } } if (mSelectedTabIndex > count) { mSelectedTabIndex = count - 1; } setCurrentItem(mSelectedTabIndex); requestLayout(); }
From source file:com.viewpagerindicator.TabMovablePageIndicator.java
public void notifyDataSetChanged() { mTabLayout.removeAllViews();//from w ww. j a va 2 s . co m PagerAdapter adapter = mViewPager.getAdapter(); IconPagerAdapter iconAdapter = null; if (adapter instanceof IconPagerAdapter) { iconAdapter = (IconPagerAdapter) adapter; } final int count = adapter.getCount(); int wordsTotalWidth = 0; 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); } TabView tabView = addTab(i, title, iconResId); wordsTotalWidth += tabView.wordWidth; } if (isTabAllDisplay) { int totalSpace = mScreenWidth - wordsTotalWidth; if (totalSpace < 0) { mPaddingEachEdge = 0; } else { mPaddingEachEdge = totalSpace / count / 2; } } if (mSelectedTabIndex > count) { mSelectedTabIndex = count - 1; } setCurrentItem(mSelectedTabIndex); requestLayout(); }
From source file:com.keithandthegirl.app.ui.custom.slidingtabs.SlidingTabLayout.java
private void populateTabStrip() { final PagerAdapter adapter = mViewPager.getAdapter(); final OnClickListener tabClickListener = new TabClickListener(); for (int i = 0; i < adapter.getCount(); i++) { View tabView = LayoutInflater.from(getContext()).inflate(R.layout.sliding_tab_view, mTabStrip, false); TextView tabTitleView = (TextView) tabView.findViewById(R.id.tabTextView); TextView showCountTextView = (TextView) tabView.findViewById(R.id.showCountTextView); TextView vipTextView = (TextView) tabView.findViewById(R.id.vipTextView); tabTitleView.setText(adapter.getPageTitle(i)); if (adapter instanceof SlidingTabPagerAdapter) { SlidingTabPagerAdapter slidingTabPagerAdapter = (SlidingTabPagerAdapter) adapter; if (slidingTabPagerAdapter.hasNewShows(i)) { showCountTextView.setText(String.valueOf(slidingTabPagerAdapter.getNewShowCount(i))); showCountTextView.setVisibility(View.VISIBLE); } else { showCountTextView.setVisibility(View.GONE); }/*from w ww .j av a2 s . c o m*/ if (slidingTabPagerAdapter.isVip(i)) { vipTextView.setVisibility(View.VISIBLE); } else vipTextView.setVisibility(View.GONE); } else { showCountTextView.setVisibility(View.GONE); vipTextView.setVisibility(View.GONE); } tabView.setOnClickListener(tabClickListener); mTabStrip.addView(tabView); } }
From source file:com.shawnway.nav.app.wtw.view.PagerSlidingTabStrip.java
private void calCircleSize() { // ?widget// w w w. j a v a 2 s . c o m float max = 0; PagerAdapter adapter = pager.getAdapter(); for (int i = 0; i < adapter.getCount(); i++) { float t = rectPaint.measureText((String) adapter.getPageTitle(i)); if (t > max) { max = t; } } circleSize = max; }
From source file:com.it520.activity.main.wight.SmartTabLayout.java
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."); }//from w ww .j a v a 2 s . co m 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); } } }
From source file:com.shine.demo.viewpager.smartTabLayout.SmartTabLayout.java
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."); }/* w w w .j a v a2s. c om*/ if (distributeEvenly) { LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) tabView.getLayoutParams(); lp.height = 0; lp.weight = 1; } if (internalTabClickListener != null) { tabView.setOnClickListener(internalTabClickListener); } tabStrip.addView(tabView); if (i == viewPager.getCurrentItem()) { tabView.setSelected(true); } } }