Reputation: 1218
I have two fragments:
public static void openWhatsNewFragment(FragmentManager fragmentManager) {
defaultTransaction(fragmentManager)
.replace(R.id.fragment_holder, new FeedFragment())
.addToBackStack(null)
.commit();
}
public static void openBookmarksFragment(FragmentManager fragmentManager) {
defaultTransaction(fragmentManager)
.replace(R.id.fragment_holder, new BookmarkFragment())
.addToBackStack(null)
.commit();
}
as the title, i dont want my fragments refresh when i switch. PS: sorry for bad English.
Upvotes: 0
Views: 256
Reputation: 2196
FragmentTransaction.replace()
always replaces the current fragment. So, the view will always be recreated when you replace a fragment. It is your job to keep the data needed into a Bundle by implementing onSavedInstanceState()
and then retrieve the data into onCreateView()
.
Upvotes: 1