@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_infinite_cycle_view_pager); final ViewPager viewPager = (ViewPager) findViewById(R.id.vp_main); viewPager.setAdapter(new MainPagerAdapter(getSupportFragmentManager())); viewPager.setOffscreenPageLimit(2); final NavigationTabStrip navigationTabStrip = (NavigationTabStrip) findViewById(R.id.nts); navigationTabStrip.setTitles("HORIZONTAL", "VERTICAL", "TWO-WAY"); navigationTabStrip.setViewPager(viewPager); }
private void setUI() { mViewPager.setAdapter( new PagerAdapter() { @Override public int getCount() { return 3; } @Override public boolean isViewFromObject(final View view, final Object object) { return view.equals(object); } @Override public void destroyItem(final View container, final int position, final Object object) { ((ViewPager) container).removeView((View) object); } @Override public Object instantiateItem(final ViewGroup container, final int position) { final View view = new View(getBaseContext()); container.addView(view); return view; } }); mTopNavigationTabStrip.setTabIndex(1, true); mCenterNavigationTabStrip.setViewPager(mViewPager, 1); mBottomNavigationTabStrip.setTabIndex(1, true); // final NavigationTabStrip navigationTabStrip = (NavigationTabStrip) // findViewById(R.id.nts); // navigationTabStrip.setTitles("Nav", "Tab", "Strip"); // navigationTabStrip.setTabIndex(0, true); // navigationTabStrip.setTitleSize(15); // navigationTabStrip.setStripColor(Color.RED); // navigationTabStrip.setStripWeight(6); // navigationTabStrip.setStripFactor(2); // navigationTabStrip.setStripType(NavigationTabStrip.StripType.LINE); // navigationTabStrip.setStripGravity(NavigationTabStrip.StripGravity.BOTTOM); // navigationTabStrip.setTypeface("fonts/typeface.ttf"); // navigationTabStrip.setCornersRadius(3); // navigationTabStrip.setAnimationDuration(300); // navigationTabStrip.setInactiveColor(Color.GRAY); // navigationTabStrip.setActiveColor(Color.WHITE); // navigationTabStrip.setOnPageChangeListener(...); // navigationTabStrip.setOnTabStripSelectedIndexListener(...); }