Android Fragments


The Fragment is a reusable class that can be attached as part of an Activity or used in several Activities.

A Fragment can represent part of the UI or be a non-UI entity. The life cycle of a Fragment is directly affected by the Activity it is attached to.

The Fragment was introduced (in Android 3.0) to accomidate larger screens i.e. the tablet.

Each Fragment has it's own layout and behavior therefore, can be utilized in different Activities.

Add a Fragment to an Activity using XML or code.

Manage a Fragment with a FragmentManager that is returned from the Activities getFragmentManager() method.

CREATED 2017-07-23 14:42:27.0

00-2A-15

UPDATED 2017-07-23 14:42:30.0

Fragment Callbacks


Call Back Called when...
onAttach associtated with an activity
onCreate the Fragment is constructed
onCreateView the UI is painted for the first time. Returns the view to paint or null if there is no view in the Fragment.
onActivityCreated() after onCreateView() method. The view is created and reference to the Context object can be made.
onStart the UI is visible.
onResume Fragment gets focus
onPause() the user is leaving the Fragment - first indication
onStop the Fragment is going to be stopped.
onDestroyView the view is being destroyed.
onDestroy to do final cleanup of the fragment but not garanteed to be called by the Android platform.

CREATED 2017-07-23 12:32:50.0

00-2A-04

UPDATED 2017-07-23 14:42:32.0

Knowledge

Dev Guide
L
I
N
K
S

DBID: db.wam

Page Server: Ithica

©2012 Leistware Data Systems

      Hello anonymous