@Override
 public void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   ImageUtil.initImageLoader(this);
   int pos = getIntent().getIntExtra("pos", 0);
   imgs = getIntent().getStringArrayListExtra("Images");
   setContentView(R.layout.activity_viewpager_example);
   ExtendedViewPager mViewPager = (ExtendedViewPager) findViewById(R.id.view_pager);
   mViewPager.setAdapter(new TouchImageAdapter());
   mViewPager.setCurrentItem(pos);
 }
Example #2
0
 public void setCurrentItem(int item) {
   if (mViewPager == null) return;
   // throw new IllegalStateException("ViewPager has not been bound.");
   mCurrentItem = item;
   mViewPager.setCurrentItem(item);
   mSelectedTabIndex = item;
   final int tabCount = mTabLayout.getChildCount();
   for (int i = 0; i < tabCount; i++) {
     final View child = mTabLayout.getChildAt(i);
     final boolean isSelected = i == item;
     child.setSelected(isSelected);
     if (isSelected) {
       animateToTab(item);
     }
   }
 }