Here is the conclusion I came to on this one >> 1. Just have the activity or fragment call a dedicated save and restore >> methods especially if the base class of your SpecialView is View.
It is not very clean doing it this way. Especially if you could do it well (even if that meant with some extra coding) by delegating the state management to the view itself. However this approach (due to clarity) could be used (like in the SnakeView API sample) if your intention is to demonstrate something else (like how a canvas works) and not focus on view state management. > 2. Use the View's capabilities of onSaveInstanceState() and ignore the "null" > from the VIew implementation This is an intermediate way where we are delegating the state management to the view but used a quick and dirty approach to plug into the framework where we don't use the BaseSavedState pattern. I don't think this is worth the trouble unless again you are using this to demonstrate something else. The primary problem with this is namespace collision of the things that you stuff into the veiw state bundle or needing to recognize your own bundle in the hierarchy. > 3. Or use the BaseSaveState pattern that is used by things like TextView etc. I have come to the conclusion that this is the best approach. However if you are specializing a view group there are strategies you need to use to deal with the "unique" id problem. Here is a sample source code for a CircleView that uses this approach and is pretty complete as to what is required to create a custom view http://satyakomatineni.com/item/4330 Thanks http://twitter.com/SatyaKomatineni http://satyakomatineni.com http://androidbook.com On Wed, Oct 24, 2012 at 9:41 AM, Satya Komatineni <satya.komatin...@gmail.com> wrote: > The literature seem to indicate a number of alterantives > > 1. Just have the activity or fragment call a dedicated save and > restore methods especially if the base class of your SpecialView is > View. > 2. Use the View's capabilities of onSaveInstanceState() and ignore the > "null" from the VIew implementation > 3. Or use the BaseSaveState pattern that is used by things like TextView etc. > > Appreciate your thoughts and comments. > > Thanks > Satya -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en