
Android Fragment : Introduction
Jul 28, 2017 · 1 min read
- Android Fragment represents a behavior or a portion of user interface in an activity
- Multiple fragments can be embedded in a single activity.
- Fragment can be used with multiple activities.
- Every fragment has its own life cycle.
- Fragment can be added/removed while activity is in running state.
- Fragment must always be embedded in an activity.
- Fragment receives its own input events.
Fragment Life Cycle

Why Fragment?
Fragment is new concept introduced in 3.0 version.
- Modular — Divide complex activity code across fragment to maintain and organize it better
- Reusable — Fragment can be used with multiple activities to reuse the code.
- Adaptable — Representing sections of a UI as different fragments and utilizing different layouts depending on screen orientation and size
