Skip to content

Instantly share code, notes, and snippets.

@yevhenRoman
Created January 23, 2020 22:56
Show Gist options
  • Save yevhenRoman/c64776df9a6b1eb382228481b40dff2a to your computer and use it in GitHub Desktop.
Save yevhenRoman/c64776df9a6b1eb382228481b40dff2a to your computer and use it in GitHub Desktop.
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
bottomNavigation = findViewById(R.id.nav_view)
val appBarConfiguration = AppBarConfiguration(
setOf(
R.id.navigation_home, R.id.navigation_dashboard, R.id.navigation_notifications
)
)
val navGraphIds = listOf(
R.navigation.home_nav_graph,
R.navigation.dashboard_nav_graph,
R.navigation.notifications_nav_graph
)
val controller = bottomNavigation.setupWithNavController(
navGraphIds = navGraphIds,
fragmentManager = supportFragmentManager,
containerId = R.id.nav_host_fragment,
intent = intent
)
// Whenever the selected controller changes, setup the action bar.
controller.observe(this, Observer { navController ->
setupActionBarWithNavController(navController, appBarConfiguration)
})
currentNavController = controller
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment