I have an activity which contains a viewpager to swipe across 4 fragments. I'm also using ActionBar.NAVIGATION_MODE_TABS to display the tabs name and allow navigating by pressing on on the tab as well as swiping
public void onCreate(Bundle savedInstanceState) {
...
this.viewPager = (ViewPager) findViewById(R.id.viewPager);
this.viewPagerAdapter = new MyViewPagerAdapter(this, getSupportFragmentManager());
this.viewPager.setAdapter(this.viewPagerAdapter);
this.viewPager.setCurrentItem(0);
actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
// Create a tab listener that is called when the user changes tabs.
final TabListener tabListener = new TabListener() {
@Override
public void onTabReselected(Tab arg0, FragmentTransaction arg1) {
}
@Override
public void onTabSelected(Tab tab, FragmentTransaction arg1) {
viewPager.setCurrentItem(tab.getPosition());
}
}
@Override
public void onTabUnselected(Tab arg0, FragmentTransaction arg1) {
}
};
// add the tabs
this.viewPager.setOnPageChangeListener(
new ViewPager.SimpleOnPageChangeListener() {
@Override
public void onPageSelected(int position) {
// When swiping between pages, select the corresponding tab.
actionBar.setSelectedNavigationItem(position);
}
});
This works fine, but when the device is in landscape orientation, the tabs are displayed as an action spinner, then the spinner content doesn't refresh anymore when swiping in the viewpager even though onPageSelected() is called with the correct position
Any idea how to fix this ?
Thanks