0

It is maybe a stupid question but I am programming in android for two month know and i still don't know when I have to use fraguments and i never feel as I need something else than activity... That's anoying because it looks like something usefull (a lot of people talk about it).

So does someone can explain me their purposes ? And in which case should I use it ?

Thanks

Eliott Roynette
  • 716
  • 8
  • 21
  • This won't probably tell you **ALL** about Fragments, but will give you a **great start**: http://developer.android.com/guide/components/fragments.html – Phantômaxx May 23 '14 at 12:23
  • I had the same question sometime ago and I found a satisfactory answer here: http://stackoverflow.com/questions/10478233/android-need-some-clarifications-of-fragments-vs-activities-and-views look – Selz May 23 '14 at 12:25
  • Thanks for your help, I think I start to understand. I need to practice a bit know. I didn't know fragument was for view management. – Eliott Roynette May 23 '14 at 12:38

1 Answers1

1

A Fragment is a piece of an application's user interface or behavior that can be placed in an Activity which enable more modular activity design. It will not be wrong if we say, a fragment is a kind of sub-acitivity.

Following are important points about fragment:

  1. A fragment has its own layout and its own behavior with its own lifecycle callbacks.
  2. You can add or remove fragments in an activity while the activity is running.
  3. You can combine multiple fragments in a single activity to build a multi-pane UI.
  4. A fragment can be used in multiple activities.
  5. Fragment life cycle is closely related to the lifecycle of its host activity which means
  6. when the activity is paused, all the fragments available in the acivity will also be stopped.
  7. A fragment can implement a behavior that has no user interface component.
  8. Fragments were added to the Android API in Honeycomb version of Android which API version 11.

for more details please visit official site. http://developer.android.com/guide/components/fragments.html

Eliott Roynette
  • 716
  • 8
  • 21
Mani
  • 3,394
  • 3
  • 30
  • 36