53.4 Creating the First Fragment
Each of the tabs on the TabLayout will display a different fragment when selected. Create the first of these fragments by right-clicking on the app -> java -> com.ebookfrenzy.tablayoutdemo entry in the Project tool window and selecting the New -> Fragment -> Fragment (Blank) option. In the resulting dialog, enter Tab1Fragment into the Fragment Name: field and fragment_tab1 into the Fragment Layout Name: field. Click on the Finish button to create the new fragment:
Figure 53-3
Edit the Tab1Fragment.kt file and, if Android Studio has not added one automatically, add an OnFragmentInteractionListener interface declaration as follows:
.
.
import android.net.Uri
.
.
interface OnFragmentInteractionListener {
fun onFragmentInteraction(uri: Uri)
}
.
.
Load the newly created fragment_tab1.xml file (located under...