On Tue, Jan 10, 2012 at 6:44 AM, Doug Gordon <gordo...@gmail.com> wrote:
> Yes I did, and it is not clear why I would want to use one vs. the > other in many cases since the end behavior seems to be the same. > In your particular use case perhaps. I have not used Fragments yet, but reading the description implies to me that if you add() you are leaving the exist list of Fragments in a given container within the Activity alone and adding your new Fragment to that list. With replace() you are wiping the container of all its existing Fragments and replacing them all with your new Fragment. I could very well have that wrong. This shouldn't be too hard for you to verify if you're already working with Fragments. > The "add" method also implies that you're adding the fragment "to > the activity", whereas replace talks about removing and adding "to > the container". > It says "Add a fragment to the activity state." Not the Activity itself but its state. "This fragment may optionally also have its view (if Fragment.onCreateView<http://developer.android.com/reference/android/app/Fragment.html#onCreateView(android.view.LayoutInflater,%20android.view.ViewGroup,%20android.os.Bundle)> returns non-null) into a container view of the activity." So you also have the option to place the Fragment in a specific container. Then if you use replace() specifying that container, those Fragments in that container would go away. Again, I haven't used Fragments and that's just what I'm gathering from reading the function definitions. YMMV. You should be able to test this. ------------------------------------------------------------------------------------------------- TreKing <http://sites.google.com/site/rezmobileapps/treking> - Chicago transit tracking app for Android-powered devices -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en