假设您有两个自定义视图
class TopLevelCustomView extends LinearLayout {
@State
TopViewState state;
TextView textView;
NestedCustomView nestedView;
@Override
public Parcelable onSaveInstanceState() {
// How to save both text view info & nested view using icepick <-- query
return saveInstanceState(this, super.onSaveInstanceState());
}
@Override
public void onRestoreInstanceState(Parcelable state) {
super.onRestoreInstanceState(restoreInstanceState(this, state));
// How to restore both text view info & nested view using icepick <-- query
}
}
class NestedCustomView extends LinearLayout {
@State
NestedViewState state;
TextView textView;
@Override
public Parcelable onSaveInstanceState() {
// How to save both text view info & nested view using icepick <-- actual query
return saveInstanceState(this, super.onSaveInstanceState());
}
@Override
public void onRestoreInstanceState(Parcelable state) {
super.onRestoreInstanceState(restoreInstanceState(this, state));
// How to restore both text view info & nested view using icepick <-- actual query
}
}
如何使用Icepick并自动保存&amp;恢复嵌套自定义视图和视图的视图状态来自TopLevelCustomView