30.4 Creating the First Fragment Class
In addition to a user interface layout, a fragment also needs to have a class associated with it to do the actual work behind the scenes. Add a class for this purpose to the project by unfolding the app -> java folder in the Project tool window and right-clicking on the package name given to the project when it was created (in this instance com.ebookfrenzy.fragmentexample). From the resulting menu, select the New -> Java Class option. In the resulting Create New Class dialog, name the class ToolbarFragment and click on OK to create the new class.
Once the class has been created it should, by default, appear in the editing panel where it will read as follows:
package com.ebookfrenzy.fragmentexample;
public class ToolbarFragment {
}
For the time being, the only changes to this class are the addition of some import directives and the overriding of the onCreateView() method to make sure the layout file is inflated...