Week 5
Lecture dates: April 24th
During this week, we will introduce you to one of the most fundamental components of Android development -- using Fragments
. Getting a good understanding of fragments is necessary in order to minimize code redundancy and practice code reusability techniques.
Your homework starting from this week onward will no doubt require you to use fragments to create reusable components. It will be difficult unless you learn how they work and, more importantly, how to implement them.
Fragments
As with any other Android concepts, the best place to start is by reading more about Fragments
in the Android Documentation website.
During lecture, we will cover all the bits and pieces about fragments, which are rather easier to explain by following along with Ted than writing them down here.
So I will only be putting links that are very useful for you as you learn to master fragments on your own.
Important Details Not to Miss:
A fragment also has its own lifecycles. Make sure you know how it works and how it differs or aligns closely with an Activity lifecycle.
You need an XML for a fragment's layout and a class that implements
Fragment
in order to create a reusable Fragment object.A fragment does not do much on its own. To utilize fragments across the entirety of your application, you read about performing fragment transactions.
Links:
Source of GitHub repo that Ted uses to teach Fragment: CW-Omnibus - Dynamic Fragment Demo
Using Fragments in Android - An example involves creating and using a Tab Bar (something we haven't taught yet so far)
This is beyond the scope of the class, but if you're interested in learning how to create a custom FragmentManager
to minimize errors when dealing with fragment transactions, then read this article.
Last updated