I think I understand the logic behind using Bundles to pass in and store values associated with a Fragment, but I wondered if someone could validate my understanding.
I believe that it makes sense to use a Bundle to pass in initial values at the time of construction of a Fragment for a number of reasons: 1) Bundles are a simple way to pass in an arbitrary number of arguments of different types, so the pattern of using Fragments is the same for everyone. This makes understanding them easier. 2) The arguments Bundle on a Fragment (setArguments, getArguments) is a convenience over having to create class member fields to keep track of the specifics of a Fragment object. 3) It is simple to take an extras Bundle from an inbound Intent and pass it to a Fragment's creation logic. This doesn't mean you always need to use a Bundle when creating a Fragment, but if you have a few or more values to pass in, a Bundle makes a lot of sense. Are there other reasons why you'd want to use Bundles in this way? Or situations where you wouldn't? The Shakespeare example that Dianne blogged about recently used a Bundle for a single int value. Was this more for demonstration purposes? Or would it have been acceptable to simply use a constructor that takes an int, and save it in a member field for later? Thanks! -- 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