Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Accused187
Copy link

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.

…r any other behaviors where the activity would be destroyed.
@ysamlan
Copy link
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.

@Accused187
Copy link
Author

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
Copy link

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
Copy link
Author

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
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants