Fragments in android

avatar

NaN years ago

Fragments in android are part of activities. It might feel confusing to understand the difference but fragments are simply nested activities. It is very used to build advance android applications.


For example, When you swipe left and right on the home screen of Instagram, you can open the camera and chat screen. All these screens are fragments inside one activity, not three activities for each screen.


The biggest drawback of activities in android is that you can perform only one task at a time. Unless you use fragments to perform many tasks at a time on a single activity.


Pros of learning fragments in android

  1. Fragments can help you create complex android applications.
  2. Fragments are lightweight compared to multiple activities.
  3. Fragments can create multi-screen UI using single activity.


Cros of learning fragments in android

  1. Multiple fragments on single activity can after the performance.
  2. You have to study activities before getting into fragments.
  3. Fragments can not be used without an activity.


In interviews, lots of questions are asked related to Fragments so I would highly recommend you learn about it basics and communication between fragments and activities.

approvedApproved by experts
Advance Topics

Neuton's Mission

We are a team of young and enthusiastic people who are passionate about education and want to help students to learn the skills they need to succeed in life. If you want to support us, please join our community.

phonephonephonephonemail