0

What scenarios using fragments what scenario using the activity , How can I make sure you when to use the activity when using fragments !

WenJackp
  • 1
  • 1

4 Answers4

2

Basically, when you want a fixed portion of the screen and the rest will be changing, you want to use fragments.

If all your app is going to be on different screens, you want to use Activities.

Anyway, at least you will need one activity to hold your fragments.

Hope this helps.

Nanoc
  • 2,381
  • 1
  • 20
  • 35
0

As i know,You need to extend the fragment when you are displaying the view into tabs. Otherwise you can extend activity.

Prasanna
  • 195
  • 2
  • 16
0

It depends on your requirement. if u want to expose your toolbar throughout your application you can use fragment both activity and fragment are quite similar . You can also use only one activity remaining things may be your fragment

M.Yogeshwaran
  • 1,419
  • 4
  • 22
  • 48
0

It depends on UI which you are creating. If you are creating Multi-Pane UI then you should use Fragment. And if you are creating some part of screen which can be reused then for that part you should create Fragment as Fragment is meant for re-usability. If you are creating stand-alone screen then you should use Activity

For more info please refer this link How to choose Activity or Fragment if both scenarios are possible?

Community
  • 1
  • 1
Harish Godara
  • 2,388
  • 1
  • 14
  • 28