In this few parts of my Android tutorial I’ll focus on a Android Fragment Tutorial. I’ll start off slow here by showing you how to switch fragments based on screen orientation, which is very commonly used.
I’ll specifically cover the basics of fragments, layout fragments, FragmentManager, FragmentTransaction, committing fragment replacements, LayoutInflator, Configuration and more.
If you like videos like this, it helps to share on Google Plus with a click here [googleplusone]
Code From the Video
portrait_fragment.xml
landscape_fragment.xml
activity_my.xml
FragmentLandscape.java
FragmentPortrait.java
MyActivity.java
Seriously love your tutorials!
😉
Thank you 🙂
Great tutorial. your explanation is simply good. easy understand the coding and its implementation
Thanks
Thank you very much 🙂
Hi derek ,thanks for the tutorial , its really detailed good and even fun 🙂 even for people who are not english native speaker like me.
A little basic question, is the procedure onCreate on myActivity is executed each time I change the orientation of my device?
I understand fragmentTransaction is responsible for replacing fragments. However,the condition to replace a fragment (=what is our orientation) is checked in onCreate procedure.
thanks!
You’re very welcome 🙂 Yes onCreate is called every time the Activity has to be re-drawn to the screen.
O love your code comments, it helps me a lot.
Thank you Derek.
I’m very happy that they help 🙂
Hi Derek!
Thanks for tutorial. It really helped me a lot . But i am not sure about one thing. Can you please tell me what is activity_my.xml for?
It is not used anywhere and i deleted it from my app and everything worked just perfect. Thank you for your answer.
Hi Daniel, You’re very welcome 🙂 activity_my.xml is normally the default xml layout for the app. I kept it there for those people that used it because it is created by default.
Hi Derek,
The support folder is not in my sdk directory structure. Am I missing a package to install from the SDK manager?