I've just about got the concept of using the Bundle
instance state to store stuff that wouldn't otherwise be stored when an Activity
is destroyed and recreated (e.g. on screen rotation). I also see that you don't need to do this for basic information for each View
, like text in a TextView
, because the system does that for you (at least for those Views that have an ID assigned). See http://developer.android.com/training/basics/activity-lifecycle/recreating.html.
But when I change the background color of a View
programmatically (I'm using a basic View
as a color swatch linked to a color picker) using setBackgroundColor()
, I find that the color is lost when the screen rotates, and reverts back to the original setting. I do have an ID assigned to the View
.
Should that color information be preserved automatically, or am I just being hopeful, and do I have to keep track of that separately and restore the color on recreation of the Activity?
Thanks.