Reputation: 13853
I use 2 different menu for my bottom navigation view called
I need to set different action based on what is the current menu inflated in my bottom navigation view. I want to make something like this
lateinit var bottomNavigationView : BottomNavigationView
if (bottomNavigationView.menu == R.menu.bottom_navigation_menu_verified) {
// do something here
}
but the code above is invalid because bottomNavigationView.menu
will return Menu
data type and R.menu.bottom_navigation_menu_verified
will return int
, type doesn't match. so how to check what is the current inflated menu in my bottom navigation view ?
java/kotlin is okay
Upvotes: 1
Views: 406
Reputation: 24012
You can probably check for a specific MenuItem
:
if (null != bottomNavigationView.menu.findItem(R.id.bottom_navigation_menu_item1)) {
// do something here
}
Upvotes: 2