• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps Simple concept question regarding fragments/main

AlexGraal

Lurker
Hey guys!

Very brief here.

What are fragments/activites. Why are there two. The tutorial I am following only has the main activity, no fragment. So why and how are the fragments used?

Thanks
 
The easiest way to think of fragments is like "mini" activities. (While not 100% technically correct, it is a good starting off point)

An Activity can hold several fragments. They were added in Android 3.0 so you could have split interfaces for tablets. Nowadays, most people use a single Activity and just change fragments to change "screens".

Have a look here at a stack overflow answer I wrote a while back:
android - How many Activities vs Fragments? - Stack Overflow

fragments.png


And here:
Preparing for Handsets | Android Developers Blog
 
Back
Top Bottom