0

Hi I just started learning android development, no tutorials clearly explained the below:

What is the difference between basic activity and basic activity with fragment in android studio 2.1

Could you please help. Thanks.

OneCricketeer
  • 179,855
  • 19
  • 132
  • 245
  • The code that the two options generate is obviously different. Is that what you are trying to ask? Otherwise, I'm fairly sure the documentation goes over both Activities and Fragments in depth – OneCricketeer Jun 13 '16 at 20:13

2 Answers2

1

activity is a place holder for fragments, fragments (as name says are parts of an activity and placeholder for widgets which mostly are complex views ( and views are like a building blocks - they have many properties - for example they could be visible or not to user )

imagine like whole android app is like Lego :

  • activity - is large white sheet of paper which holds small paper cards (like fragments) attached with plasticine or glue ( by using fragment manager transaction)
  • fragments - small pieces of colored paper
  • widget - more complex views like small construction from "Lego blocks"
  • views & other not visible components - like Lego blocks

to build a widget you connect the blocks(views, some other not visible components), to build fragment you place widgets - everything is bound by logic (code for those building blocks - which talks each to another like component of an view, fragment or an activity)

ceph3us
  • 7,326
  • 3
  • 36
  • 43
-1

When you click on Activity, Android Studio will create a Activity, its layout file and other resources for you for free.

Similarly when you click on Activity with Fragment, Android studio will create a activity with a fragment in it. This fragment will be occupying whole width and height of the screen.

Arpit Ratan
  • 2,976
  • 1
  • 12
  • 20