FRAGMENTS AND MULTIPLATFORM
SUPPORT
FRAGMENTS
• Android Fragment is the part of activity, it is also known as
sub-activity.
• There can be more than one fragment in an activity.
Fragments represent multiple screen inside one activity.
• Android fragment lifecycle is affected by activity lifecycle
because fragments are included in activity.
FRAGMENTS
• Each fragment has its own life cycle methods that is affected
by activity life cycle because fragments are embedded in
activity.
• Fragments in Android can be added, removed, or replaced
dynamically i.e., while the activity is running.
FRAGMENTS
• The usage of Fragment in an android app totally depends on
the screen size of the device on which the app is being used.
• If the screen size is big, then we can easily show 2 or maybe
more fragments on the screen, but if the display size is smaller, it
is advised to use Fragments in separate activities.
Lifecycle methods of Fragment
Lifecycle methods
• onAttach(): attaches the fragment onto the host activity.
• onCreate() : here fragment got created.
• onCreateView(): here fragment views got created.
• onActivityCreated(): is a lifecycle method in the Android Fragment
lifecycle that is called when the Fragment's activity has been fully
created and its view hierarchy is completely instantiated.
Lifecycle methods
• onStart(): it invokes when fragment got visible.
• onResume(): this method invokes when fragment start
interacting.
• onPause(): this method invokes when fragment stop
interacting.
• onStop() : this method invokes when fragment no more
visible.
• onDestroyView(): this method destroys the view of it.
• onDestroy(): this method invokes to destroy fragment.
FRAGMENTS AND MULTIPLATFORM SUPPORT.pptx

FRAGMENTS AND MULTIPLATFORM SUPPORT.pptx

  • 1.
  • 2.
    FRAGMENTS • Android Fragmentis the part of activity, it is also known as sub-activity. • There can be more than one fragment in an activity. Fragments represent multiple screen inside one activity. • Android fragment lifecycle is affected by activity lifecycle because fragments are included in activity.
  • 3.
    FRAGMENTS • Each fragmenthas its own life cycle methods that is affected by activity life cycle because fragments are embedded in activity. • Fragments in Android can be added, removed, or replaced dynamically i.e., while the activity is running.
  • 5.
    FRAGMENTS • The usageof Fragment in an android app totally depends on the screen size of the device on which the app is being used. • If the screen size is big, then we can easily show 2 or maybe more fragments on the screen, but if the display size is smaller, it is advised to use Fragments in separate activities.
  • 6.
  • 7.
    Lifecycle methods • onAttach():attaches the fragment onto the host activity. • onCreate() : here fragment got created. • onCreateView(): here fragment views got created. • onActivityCreated(): is a lifecycle method in the Android Fragment lifecycle that is called when the Fragment's activity has been fully created and its view hierarchy is completely instantiated.
  • 8.
    Lifecycle methods • onStart():it invokes when fragment got visible. • onResume(): this method invokes when fragment start interacting. • onPause(): this method invokes when fragment stop interacting. • onStop() : this method invokes when fragment no more visible. • onDestroyView(): this method destroys the view of it. • onDestroy(): this method invokes to destroy fragment.