34,333
edits
Changes
→= Creating the First Fragment Class
With the layout for the first fragment implemented, the next step is to create a class to go with it.
== 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 -> Kotlin File/Class option. In the resulting Create New Class dialog, name the class ToolbarFragment, change the Kind setting to Class and click on OK to create the new class.