A Fragment એ UI નો પુનઃવપરાશ યોગ્ય ભાગ છે જે Activity ની અંદર રહે છે — એક મોડ્યુલર, સ્વ-સમાયેલ UI ઘટક જેની પોતાની lifecycle છે. Fragments લવચીક, પુનઃવપરાશ યોગ્ય UIs સક્ષમ કરે છે અને આધુનિક single-Activity આર્કિટેક્ચરમાં કેન્દ્રીય છે.
Fragment શું છે
A FRAGMENT = a reusable, modular piece of UI hosted inside an Activity:
→ has its OWN lifecycle (tied to but distinct from the host activity's)
→ multiple fragments can be combined in one activity; reused across activities
→ represents a portion of the screen (or a whole screen's content)
→ Think: an activity can host one or more fragments that make up its UI.
Fragments વિરુદ્ધ Activities
ACTIVITY → a top-level screen/entry point; heavier; managed by the OS; declared in manifest
FRAGMENT → a UI portion WITHIN an activity; lighter, reusable, modular; managed by the
activity's FragmentManager; NOT declared in the manifest
→ Fragments are more flexible/reusable; activities are the containers/entry points.
