Added code to save the current screen to handle orientation changes or an #4

Open
wants to merge 1 commit into
from

Projects

None yet

3 participants

@Accused187

Added code to save the current screen to handle orientation changes or any other behaviors where the activity would be destroyed. This should resolve the pending issue.

@Accused187 Accused187 Added code to save the current screen to handle orientation changes o…
…r any other behaviors where the activity would be destroyed.
9c9df82
@ysamlan
Owner
ysamlan commented Jun 3, 2011

This looks great; I'll check it out and pull it back in as soon as I get a chance to test it a bit.

@ysamlan

This code doesn't seem to actually work (try running the demo app and rotating the screen), on either the simple or tabbed examples. Can you confirm that the demos work for you with your patch?

@Accused187

That's interesting...it is working in my own implementation but you're correct it is not working in the demo.

The only difference I can think of right off the bat is that I'm using the HorizontalPager as my global container for everything and using statements for different xml layouts whereas the demo project isn't. I will try and investigate further and see what I come up with.

@shilgapira

This code works well. The state isn't being persisted properly because of two problems with the demo activities.

  • HorizontalPagerDemo: Android only saves states for views that have an id set for them. Since this activity instantiates its pager by code, we need to call setId() explicitly for this to work.
  • TabbedHorizontalPagerDemo: In this case the RadioGroup.OnCheckedChangeListener listener was being invoked right after the state of the view was persisted and it was messing things up. The listeners should be set in the onResume() method for this not to happen.

I've bundled these changes along with additional fixes in a pull request.

@Accused187

Apologies for the late reply, I've been away on vacation for the past 2 1/2 weeks so I haven't done work on this.

The saved state only working on views with an id certainly explains why it worked in my project versus the demo included here as I load my layouts through XML where I always have id attributes.

Kudos on the radio button fix as well.

Thanks for picking up my slack. :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment