Android View onSaveInstanceState not called

后端 未结 2 1359
野趣味
野趣味 2021-02-07 10:06

I am working with CustomView which extends some Android view like FrameLayout. In my layout I use a ViewPager with a custom PagerAdapter.

The problem is that my

2条回答
  •  北恋
    北恋 (楼主)
    2021-02-07 10:45

    Saving State by Default

    We now have everything in place for our view to save and restore its state. However, this will not happen by default. If you want instances of your view to save state automatically, you can add this line to the init method:

    setSaveEnabled(true);
    

    Whether or not to do this is up to you. Even if your view does not save state by default, users of the view can always enable saving state by calling setSaveEnabled(true), or by specifying android:saveEnabled=“true” in the layout xml.

提交回复
热议问题