用于保存和恢复组合自定义视图的Icepick

时间:2016-11-08 16:41:26

标签: android android-custom-view

假设您有两个自定义视图

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

的其他观点

0 个答案:

没有答案