I have custom View
which is dynamically added multiple times in same activity.
Each of custom view instance has beside other stuff a
if you need apply setSaveEnabled for all hierarchy:
public static void SaveEnableViewAndChildren(this View view, bool val)
{
if (view == null)
return;
view.SaveEnabled = val;
var viewGroup = view as ViewGroup;
if (viewGroup == null)
return;
for (int i = 0; i < viewGroup.ChildCount; i++)
SaveEnableViewAndChildren(viewGroup.GetChildAt(i), val);
}
You can use View.setSaveEnabled (boolean enabled) method.
It's also possible to disable automatic state saving via xml
using saveEnabled
attribute android:saveEnabled="false"