Reputation: 24185
The demo project provided by google for using the Youtube API. which allow developers to include a youtube player inside there app. I noticed to demoes one is using YouTubePlayerView and the other used YouTubePlayerFragment. I can't really figure out the difference.
Maybe there is a technical difference. What is it?
Upvotes: 0
Views: 1063
Reputation: 3468
Fragments: "A Fragment represents a behavior or a portion of user interface in an Activity. You can combine multiple fragments in a single activity to build a multi-pane UI and reuse a fragment in multiple activities. You can think of a fragment as a modular section of an activity, which has its own lifecycle, receives its own input events, and which you can add or remove while the activity is running (sort of like a "sub activity" that you can reuse in different activities)."
http://developer.android.com/guide/components/fragments.html
Views: "This class represents the basic building block for user interface components. A View occupies a rectangular area on the screen and is responsible for drawing and event handling. View is the base class for widgets, which are used to create interactive UI components (buttons, text fields, etc.). The ViewGroup subclass is the base class for layouts, which are invisible containers that hold other Views (or other ViewGroups) and define their layout properties."
http://developer.android.com/reference/android/view/View.html
What's the difference? "So, the main reason to use Fragments are for the backstack and lifecycle features. Otherwise, custom views are more light weight, simpler to implement, and have the advantage that they can be nested."
What is the benefit of using Fragments in Android, rather than Views?
Hopefully this help clears things up.
Upvotes: 1