我有一个活动,其中包含一个浏览4个片段的viewpager。 我也使用ActionBar.NAVIGATION_MODE_TABS来显示选项卡名称,并通过按下选项卡以及滑动来导航
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);
}
});
这样可以正常工作,但是当设备处于横向时,选项卡显示为动作微调器,然后在viewpager中滑动时微调器内容不再刷新,即使使用正确的位置调用onPageSelected()
知道如何解决这个问题吗?
由于