Reputation: 372
I have a container to frame fragments on the screen. I use the following code to replace fragment:
getSupportFragmentManager()
.replace(R.id.container, MyFragment.newInstance(), "same_fragment_tag")
.addToBackStack(null)
.commit();
If I call it a couple of times, and after, trying to find the fragment with:
Fragment target = getSupportFragmentManager().findFragmentByTag("same_fragment_tag");
Which instance of the fragment would I get?
Upvotes: 1
Views: 845
Reputation: 424
It will look for the last fragment that has been added to the fragment manager.
If it's unable to find it then it will look at all fragments that still are active and haven't been removed.
Upvotes: 1