From the course: Android Compose with Kotlin

Unlock this course with a free trial

Join today to access over 24,800 courses taught by industry experts.

Handle navigation of navigation item events

Handle navigation of navigation item events - Kotlin Tutorial

From the course: Android Compose with Kotlin

Handle navigation of navigation item events

- [Instructor] So far, we have three items on our bottom bar, yet nothing happens when we click on them. Let's wire them up to take our users to the correct screen. This is going to require use of our nav host controller. So for that, what I'm going to do is add a new parameter to our bottom bar, and it's going to be the nav controller. So I'll just paste that here for now. And then we can go to our bottom bar class and we'll add that as one of the parameters. We'll come here and we'll add a new parameter for our nav host. And this is going to be of type nav host Controller. Okay. Now we need to make use of it. Every time someone clicks on one of the navigation bar items, we want them to go to the corresponding screens route. So for that, we'll update the on click function, and that's down here on line number 32. We're going to provide the nav controller and make a call to its navigate function, passing in the desired route, associated with the screen, and that's it. Let's deploy the…

Contents