Reputation: 5974
I am wondering is there any reason to do one over the other. I have been adding fragments via xml and using show/hide. I wanted to learn about replace/add/remove so I tried to add them programmatically. This has led to problems fragment remove issue and just seems less straight forward to me.
It also seems easy to place them via xml, whilst I'm still not sure how to programatically (as you don't have a reference to the fragment in the xml of the view that youa re adding it to?). Is there any reason for me to add fragments programmatically?
Upvotes: 1
Views: 444
Reputation: 86948
Fragments added in XML cannot be replaced or removed, other than that major limitation choose whichever method is easiest for you.
Upvotes: 4