I\'m using the following example to impliment my viewPager: http://code.google.com/p/viewpagerexample/issues/list
The problem with this example is that I can\'t figure o
I encountered same problem. When I initialize ViewPager, the indicator position was 0. This may depends on amount of calculating for Pager contents. I use ViewTreeObserver like below.
mGlobalLayoutListener = new ViewTreeObserver.OnGlobalLayoutListener() {
@Override
public void onGlobalLayout() {
mViewPager.setCurrentItem(newPosition);
removeOnGlobalLayoutListener(mSlidingTabLayout.getViewTreeObserver(), mGlobalLayoutListener);
}
};
mSlidingLayout.getViewTreeObserver().addOnGlobalLayoutListener(mGlobalLayoutListener);
and,
private void removeOnGlobalLayoutListener(ViewTreeObserver observer, ViewTreeObserver.OnGlobalLayoutListener listener) {
if (observer == null) return;
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) {
observer.removeGlobalOnLayoutListener(listener);
} else {
observer.removeOnGlobalLayoutListener(listener);
}
}
In this way, also never to bother with time setting of delay.