From the course: Android Development Essential Training: 3 Navigation

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Handle navigation of menu events

Handle navigation of menu events - Android Tutorial

From the course: Android Development Essential Training: 3 Navigation

Start my 1-month free trial

Handle navigation of menu events

- [Instructor] When a user clicks on one of the items in our bottom navigation view, we'd like to take them to the corresponding screen. Currently, nothing happens because we're not listening for the action. To fix that, we'll move over to Android studio and open up our main activity class. Inside of our onCreate method, we'll set a listener for a bottom navigation view. We can get access to our view by using the binding class. So right here inside of onCreate, we'll come to the bottom, we'll access our binding, and then we'll get the bottom navigation view. Next, we're going to set the on navigation items selected listener. Similar to how we use the wind statement for determining which menu item was clicked on our toolbar, we're going to do the same thing here for our navigation view. The listener provides the menu item that was selected in the callback. And to make it easier for us to read, I'm going to name that…

Contents