Skip to content

Instantly share code, notes, and snippets.

@erdalkaymak
Last active July 5, 2021 14:10
Show Gist options
  • Select an option

  • Save erdalkaymak/40d785601e2ce7fd669ae5b6de6371ea to your computer and use it in GitHub Desktop.

Select an option

Save erdalkaymak/40d785601e2ce7fd669ae5b6de6371ea to your computer and use it in GitHub Desktop.
private fun initialize() {
val fragmentList = arrayListOf<Fragment>(
HourlyWeatherDetailFragment(), WeeklyWeatherDetailFragment()
)
val tabTitles = arrayListOf(
"Hourly Weather", "Weekly Weather"
)
val adapter = ViewPagerWeatherAdapter(
fragmentList,
childFragmentManager,
lifecycle
)
viewPager2.adapter = adapter
TabLayoutMediator(tabLayout, viewPager2) { tab, position ->
tab.text = tabTitles[position]
viewPager2.setCurrentItem(tab.position, true)
}.attach()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment