ایک Fragment ایک دوبارہ استعمال ہونے والا UI کا حصہ ہے جو ایک Activity کے اندر رہتا ہے — ایک ماڈیولر، خود مختار UI کمپوننٹ جس کا اپنا lifecycle ہے۔ Fragments لچکدار، دوبارہ استعمال ہونے والے UIs کو فعال بناتے ہیں اور جدید single-Activity architectures میں مرکزی ہیں۔
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.
