PagerSlidingTabStrip icon indicating copy to clipboard operation
PagerSlidingTabStrip copied to clipboard

ViewPager.setCurrentItem() doesn't sync to tab if page is not visible when called

Open nadiasvertex opened this issue 11 years ago • 1 comments

I have an application that has two nested ViewFlippers. Inside the most nested ViewFlipper is a fragment that contains a PagerSlidingTabStrip. In general the strip works fine, but in many cases I want to set the starting tab before the page is visible to the user.

When I call ViewPager.setCurrentItem() and then called the parent ViewFlipper.setDisplayedChild(), the ViewPager shows the right content but the tab strip is not correctly synchronized.

I added "scrollToChild(position, 0);" in "public void onPageSelected(final int position)" inside the PagerSlidingTabStrip's PageListener. This does not fix the problem because the tab container has not yet laid out the children, so the x offset of all the tabs are 0.

I'm not sure how to fix or work around this issue. Any suggestions?

nadiasvertex avatar Aug 06 '13 15:08 nadiasvertex

+1 Correct fragment is always displayed. The tab strip indicator is on the wrong tab if the app is already started. Otherwise, on fresh app's start, they match.

@nadiasvertex take a look at #75

dentex avatar May 03 '14 14:05 dentex