Retain the Fragment object while rotating

后端 未结 6 1259
滥情空心
滥情空心 2020-12-01 00:18

I have developed an app in Honeycomb and I am using fragments.
This is my app

  • I have an Activity (Say A1) and in that there is a fragment
  • Initi
6条回答
  •  暖寄归人
    2020-12-01 00:45

    Use onAttachFragment() in your Activity to reassign the object:

    @Override
    public void onAttachFragment(Fragment fragment) {
        if (fragment instanceof MyFragment)
            this.myFragment = (MyFragment) fragment;
    }
    

提交回复
热议问题