2

Issue

I am using PagerSlidingTabStrip library which I am loving. The implementation I have is the minimum to get the tabs working as explained in project readme. The only thing I want to adjust is for instance, when I have 3 tabs and I touch on tab 3 from tab 1, the viewpager shows the content of tab 2 as it scrolls to tab 3. I suspected this is a viewpager issue.

Question

How can I jump from tab 1 to tab 3 without showing the content of tab 2 on the way? I'm going to have a map on tab 2, so I don't like having it trying to load that UI.

awonderer
  • 665
  • 9
  • 26

2 Answers2

1

You could override setUserVisibleHint event of the fragment to know if its visible to the user and then load your data. something like following:

boolean isContentLoaded = false;

@Override
public void setUserVisibleHint(boolean isVisibleToUser) {
   super.setUserVisibleHint(isVisibleToUser);
   if (isVisibleToUser && !isContentLoaded ) {
   loadContent(); 
   isContentLoaded = true;
   }
}
Khalid ElSayed
  • 278
  • 1
  • 5
  • 20
  • Check this question for more details http://stackoverflow.com/q/20347665/1260459 .. i just can't add it in comment because i haven't reached 50 reputation – Khalid ElSayed Mar 25 '14 at 02:28
0

You can use this:

viewPager.setCurrentItem(2,false); // first(tabNumber, (smoothScroll) make it false)
Spoody
  • 2,852
  • 1
  • 26
  • 36
Erselan Khan
  • 692
  • 6
  • 13