Android Studio 3.5 Development Essentials - Kotlin Edition was published on September 3, 2019. The current revision is 1.0. The revision of your copy of the book can be found in the copyright page at the start of the book.
52.4 Creating the First Fragment
This section incorrectly states that the Include fragment factory methods? and Include interface callbacks?options should be disabled. These should, in fact, be enabled before creating the new fragment.52.7 Creating the Pager Adapter
Since the book was published Google made some changes to the FragmentPagerAdatper class. To avoid syntax errors, the TabPagerAdapter class should now be implemented as follows:
package com.ebookfrenzy.tablayoutdemo import androidx.fragment.app.Fragment import androidx.fragment.app.FragmentManager import androidx.fragment.app.FragmentPagerAdapter class TabPagerAdapter(fm: FragmentManager, private var tabCount: Int) : FragmentPagerAdapter(fm, BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT) { override fun getItem(position: Int): Fragment { when (position) { 0 -> return Tab1Fragment() 1 -> return Tab2Fragment() 2 -> return Tab3Fragment() 3 -> return Tab4Fragment() else -> return Tab1Fragment() } } override fun getCount(): Int { return tabCount } }
If you have encountered an issue with the book not listed above please contact us as at [email protected] and we will work to resolve the issue for you as quickly as possible.