Android TutorialsNo Comments

1367 views.

A fragment can be many things, but for the purposes of this tutorial, it is a module of code that holds part of the behavior and/or UI of an activity. As the name intimates, fragments are not independent entities, but are subservient to a single activity.
In many ways, they resemble and echo the functionality of activities.
Imagine for a moment that you’re an activity. You have a lot to do, so you’d employ a few mini-me’s to run around and do your laundry and taxes in exchange for lodging and food. That’s kind of like the relationship between activities and fragments.
And just like you don’t actually need a few minions to do your bidding, you don’t have to use fragments. However, if you do use them and us

activity_main.xml

FragmentActivity.java

SecondActivity.Java

activity_second.xml

FirstFragmnet.java

first_frag.xml

SecondFrag.java

child.xml

manifestfile.xml

Output:

droid@screen-1 droid@screen-2 droid@screen-3

Be the first to post a comment.

Add a comment