I turn on the "don't keep activity" develop option.
In activity A,there is a viewpager.
Then Activity a jump to Activity B, then press back button return to A,this time viewpager's setCurrentItem() method don't work normally.Unnormally means don't trigger onPageSelected() method in ViewPager.OnPageChangeListener,and at the same time the related Tablayout don't perform right.
I've tried call the method in viewpager.post() (the solution written in other post in stackoverflow,like this post).
By the way,i use Android Annotation,and i call the setCurrentItem() in @AfterViews.
Asked
Active
Viewed 330 times
0
-
Can you post the link? – Nigam Patro Nov 26 '15 at 10:38
-
@Nigam Patro You mean the related solution post? I've updated. – lirui Nov 26 '15 at 10:51
2 Answers
1
Try this code:
@Override
void onStart(Bundle savedInstanceBundle){
if (savedInstanceBundle != null){
viewPager.setCurrentItem(savedInstanceBundle.getInt(VIEWPAGER_PAGE);
}
}
@Override
void onSavedInstanceState(Bundle outState){
// Put your current ViewPager Page here;
outState.putInt(VIEWPAGER_PAGE, page));
}

Tin Tran
- 2,265
- 1
- 14
- 17
0
I've find the reason. It caused by the ViewPager's onSaveInstanceState and onRestoreInstanceState. I don't know the detailed reason now, i'll post the detailed answer when i know.

lirui
- 1,433
- 1
- 12
- 19