Reputation: 5717
I have several custom components which extends LinearLayout
.
Now I want to save/restore their state when screen orientation changes, but I can't do it from activity's onSaveInstanceState
/onRestoreInstanceState
because I need it to be flexible. It means I have to override those functions in the LinearLayout
directly, but I couldn't find any examples.
Can somebody show me a code snippet how can I use it to store several strings and booleans? Of course every component have an unique ID.
Thanks in advance
Upvotes: 2
Views: 1801
Reputation: 5717
The solution is to create custom Parcelable
for the component and use it in onSaveInstanceState
and onRestoreInstanceState
. A bit more detailed explanation can be found here: http://prasanta-paul.blogspot.com/2010/06/android-parcelable-example.html
Upvotes: 1