astuetz / PagerSlidingTabStrip

An interactive indicator to navigate between the different pages of a ViewPager
139 stars 44 forks source link

setCurrentTab #27

Closed Shusshu closed 11 years ago

Shusshu commented 11 years ago

Ability to set the current tab.

For example I would like to directly see the middle tab

ghost commented 11 years ago

http://developer.android.com/reference/android/support/v4/view/ViewPager.html#setCurrentItem(int)

Shusshu commented 11 years ago

yes but it didn't switch the proper tab selection....

Benoit Billington

On Wed, Jul 10, 2013 at 10:17 PM, Andreas Stütz notifications@github.comwrote:

http://developer.android.com/reference/android/support/v4/view/ViewPager.html#setCurrentItem(int)

— Reply to this email directly or view it on GitHubhttps://github.com/astuetz/PagerSlidingTabStrip/issues/27#issuecomment-20769972 .

ghost commented 11 years ago
pager = (ViewPager) findViewById(R.id.pager);
pagerStrip = (PagerSlidingTabStrip) findViewById(R.id.pager_tab_strip);

pagerAdapter = new MyPagerAdapter(this, getSupportFragmentManager());
pager.setAdapter(pagerAdapter);

pagerStrip.setViewPager(pager);

pager.setCurrentItem(3);

works for me.

Shusshu commented 11 years ago

It was a problem somewhere else ;) thx

shakmak commented 10 years ago

I am facing issue when i add following extra lines to above code. final int pageMargin = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 4, getResources().getDisplayMetrics()); mPager.setPageMargin(pageMargin);

ViewPager shows correct tab but pagerStrip show next tab selected.

hongzhou85 commented 10 years ago

@shakmak I'm seeing the same problem too. Does the sequence of these settings affect it? Have u overcome this?

shakmak commented 10 years ago

@hongzhou85 I tried changing sequence but that didn't help. So i had to remove pageMargin to make it work. So issue is when you set some PageMargin

DevCCC commented 9 years ago

Hi! @astuetz nice example and its become too much usefull for me. I have faced problem that is tabstrip not scroll when i set current item in view pager, tab get selected properly but it does not scrolls to visible area.

satyapolanomaly commented 9 years ago

how to load view only when specific tab is focused