0

It seems like there are two options when you want to show the user a new screen:

  1. Start a new activity (i.e. startActivity(Intent))
  2. Swap fragments (i.e. FragmentTransaction)

What is the difference? Which one should be used?


Example

I want the user to be able to navigate between 3 screens. Each one is in a fragment. I can use ...

  1. 3 single-fragment activities.
  2. 1 activity, which dynamically switches fragments.
firyice
  • 527
  • 7
  • 24
  • 3
    this may help http://stackoverflow.com/questions/10478233/android-need-some-clarifications-of-fragments-vs-activities-and-views – wtsang02 Jun 13 '13 at 16:41
  • Fragments are used within an activity. Do a little more research on: http://developer.android.com/guide/components/fragments.html – Ryan Sayles Jun 13 '13 at 17:42

1 Answers1

2

An activity is a higher-level UI element that often contains fragments. If you are using fragmentTransaction, then you would be swapping fragments within an activity. A whole new activity would be if you were switching to a functionally separate section of your app, for example.

check out these for reference: Activities, Fragments

Ryan Chipman
  • 393
  • 2
  • 5
  • 15