Skip to content

Instantly share code, notes, and snippets.

@nanofi
nanofi / Helper.kt
Last active October 27, 2019 04:25
Workaround for fixing the issue where NavigationView does not correctly control `IsChecked` of the submenus
class Helper {
companion object {
fun setupWithNavController(navigationView: NavigationView, navController: NavController) {
navigationView.setNavigationItemSelectedListener { item ->
val handled = NavigationUI.onNavDestinationSelected(item, navController)
if (handled) {
val parent = navigationView.parent
if (parent is DrawerLayout) {
parent.closeDrawer(navigationView)