How to setOnNavigationItemListener on BottomNavigationView in android using Kotlin?

You can use this format of code:

bottomNavigation.setOnNavigationItemSelectedListener { item ->
    when (item.itemId) {
        R.id.action_favorites -> {
        }
        R.id.action_schedules -> {
        }
        R.id.action_music -> {
        }
    }
    true
}

You can use below code

bottom_navigation.setOnNavigationItemSelectedListener {
            var selectedFragment: Fragment = A()
            when (it.itemId) {
                R.id.action_item1 -> selectedFragment = A()
                R.id.action_item2 -> selectedFragment = B()
                R.id.action_item3 -> selectedFragment = C()
            }
            val transaction = fragmentManager.beginTransaction()
            transaction.replace(R.id.frame_layout, selectedFragment)
            transaction.commit()
            return@setOnNavigationItemSelectedListener true
        }

use must add annotation for return the lambda only

 bottomNavigation.setOnNavigationItemSelectedListener { item ->
        when(item.itemId){
            R.id.home -> {}

            R.id.group -> {}

            R.id.profile -> {}
        }
        return true
    }