firyice
firyice

Reputation: 527

New activity or new fragment?

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.

Upvotes: 0

Views: 854

Answers (1)

Ryan Chipman
Ryan Chipman

Reputation: 393

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

Upvotes: 2

Related Questions