Reputation: 807
I have an activity that all it does is it displays a fragment. under some certain circumstances when navigating back and from the activity, the activity gets recreated. The problem is that in this case, the fragment inside the activity is there (it is displayed after the activity is recreated) but not attached to the activity.
how can I reattach the fragment to the activity ?
Upvotes: 1
Views: 1586
Reputation: 6704
You can call the Fragment.setRetainInstance(true)
. Basically, this will let you use the same instance of the fragment regardless of Activity's condition.
Here is what says the doc and here goes an excellent tutorial to get you started.
Upvotes: 1