Vibhor Bhardwaj
Vibhor Bhardwaj

Reputation: 3101

Advantage of using Fragments on small devices

If I want to make an android application which will be used only on small devices not on tablets. So what is advantage of using fragments with single FragmentActivity ,over using normal Activity.

Somebody told me the reason that because fragments are light weights than Activities ,so it's related to performance advantage on small devices.

Is any other visible advantage on small devices?

Upvotes: 0

Views: 82

Answers (1)

Nikhil Musale
Nikhil Musale

Reputation: 332

I'd say Fragments are useful in two scenarios: if you split up views on some devices/orientations and show them in two activities and show all the content in one on other devices. That would be a use case if you go on a tablet or maybe even in landscape mode on a phone: e.g. you show the list of items and the details on one screen. on a phone or in portrait mode you just show one part.

I wouldn't see any reason for using Fragments for every View and I guess it would just be an overhead. I'm only using them in the first use case and I'd say here it is a simplification.

Another use case are reusable views. So if you have some views that are visible on different activities and also perform some actions you could put this behaviour into a fragment and then reuse it. Obviously you could probably do that with custom widgets too.

Upvotes: 1

Related Questions