I've got a ViewPager that should change the page displayed upon orientation 
change.

What I would like to achieve is to restart from the first fragment when i 
switch from landscape to portrait or vice-versa.

I supposed was just necessary to set a mViewPager.setCurrentItem(0, false); 
in the onCreate statement but it doesn't seems to work: It seems that the 
last position displayed is in someway cached and automatically restored by 
the system.

I've logged all the steps involved by the adapter and by 
the SimpleOnPageChangeListener and I really don't understand what could be 
wrong...

//Turning to the third page in Portrait Mode
10-22 16:51:25.781: D/ViewerActivity(11381): onPageSelected - position 2
10-22 16:51:26.039: D/ViewerActivity(11381): destroy 0
10-22 16:51:26.039: D/ViewerActivity(11381): instatiate 3
10-22 16:51:26.039: D/ViewerActivity(11381): getItem 3

//Switched to Landscape: call mViewPager.setCurrentItem(0); in the onCreate 
method
10-22 16:51:30.734: D/ViewerActivity(11381): current Item: 0

//Adapter calls restore state
10-22 16:51:30.761: D/ViewerActivity(11381): restoreState

That's what is not clear to me: a call to 
the SimpleOnPageChangeListener.onPageSelected is issued with the same value 
as the last page shown before the orientation change

*10-22 16:51:30.761: D/ViewerActivity(11381): onPageSelected - position 2*
*
*
//the adapter Instantiate the current and the adjacents pages
10-22 16:51:30.801: D/ViewerActivity(11381): instatiate 2
10-22 16:51:30.801: D/ViewerActivity(11381): getItem 2
10-22 16:51:30.801: D/ViewerActivity(11381): instatiate 1
10-22 16:51:30.801: D/ViewerActivity(11381): getItem 1
10-22 16:51:30.804: D/ViewerActivity(11381): instatiate 3
10-22 16:51:30.804: D/ViewerActivity(11381): getItem 3

Anyone has suggestions?

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to