Create your account

Already have an account? Login here

Create account

51. Adding a Fragment to XML

Design + Code an Android App from Scratch

Woah, wait a second..

Scrounge up some loose change to buy this course, or login to your account to view this lesson.

Alright, buy it for $25 Or login to your account if you purchased already.

This video shows how to add a Fragment to XML directly. In the first step, create an activity and its layout file. Create a class that extends the or and override the onCreateView method. Define a layout for the fragment that contains all the UI widgets which you want to display inside the Fragment. Link this layout inside onCreateView using a Layout Inflater. Create the fragment tag in the XML layout of the Activity and specify the class attribute to point to the Java class file of the Fragment that you created earlier.

Course Cirriculum