View reuse in fragments android

前端 未结 3 961
你的背包
你的背包 2021-02-03 13:27

I am trying to save my View states in my fragment but I am concerned I make be leaking my Activity. Here is what I am doing:

@Override
public View onCreateView(         


        
3条回答
  •  花落未央
    2021-02-03 13:38

    I am trying to save my View states in my fragment

    In order to save and retain view's state you can just use View.onSaveInstanceState () and View.onRestoreInstanceState (Parcelable state)

    It will help you to handle saving and restoring view state independantly from neither activity or fragment. See this answer for more information about it (how to prevent custom views from losing state across screen orientation changes)

提交回复
热议问题