0

当我旋转设备时,ImagePagerActivity 显示第 1 页(在滚动视图中)。如何解决?谢谢。

4

1 回答 1

1
public class ImagePagerActivity extends BaseActivity {

    private static final String STATE_POSITION = "STATE_POSITION";

    ViewPager pager;

    public void onCreate(Bundle savedInstanceState) {
        // ...

        if (savedInstanceState != null) {
            pagerPosition = savedInstanceState.getInt(STATE_POSITION);
        }

        // ...

        pager.setCurrentItem(pagerPosition);
    }

    public void onSaveInstanceState(Bundle outState) {
        outState.putInt(STATE_POSITION, pager.getCurrentItem());
    }

    ...
}
于 2013-02-24T15:59:40.143 回答