‫Now let's continue adding the functionality for our drawer layout.
‫So I need to change it first to late initial releasing and.
‫I will remove this.
‫And here I need to set it.
‫Draw layout equal find view by ID, not nav view.
‫It's the draw.
‫Layout.
‫If I go to here, I go up.
‫I need to add an ID to it.
‫Draw layout.
‫Okay.
‫Find view by id draw layout.
‫So make a clean project and everything will work fine.
‫So the drawer layout is here.
‫We are referencing this layout, the nav drawer layout.
‫Okay.
‫And here drawer layout dot close drawers.
‫You can see that everything is working fine.
‫So back to our when switch the conditional statements here.
‫So here is the first one.
‫The second one.
‫or.id dot message.
‫So this lambda expression will open for us and call the method replace fragment.
‫And here I will go and replace the message.
‫Fragment.
‫Then r.id dot settings and I need to paste here the settings fragment and the last thing I need to replace
‫is r.id dot login replace fragment.
‫And I need to change the settings fragment.
‫Okay, So this is very important.
‫I need to add this lambda expression and here I need to make true to set navigation item selected listener
‫to true and I will remove these extra spaces.
‫Okay, so it's very simple.
‫Till now we've created the one expression to select allow the user to select from these four options
‫the home message settings and login and replace the correct fragment with the correct display.
‫The last thing I need to make is to override the function called on options item selected.
‫And we've seen this in the previous videos when talking about the menus in Android, so I need to override
‫it in order to display my menu view that I have created.
‫So toggle on option item selected.
‫I will pass the item and return true.
‫Otherwise it will return.
‫Super dot on option.
‫Item selected listener and pass the item.
‫So this is our code.
‫Now let's run our application and see if there is any error to correct and debug the app.
‫And here we go.
‫This is our navigation drawer application.
‫So if we click on this, you can see this toggle button.
‫This is our navigation.
‫You see the navigation header and these are the options.
‫So if I click on home page, you can see home fragment is displayed, the message fragment, the settings
‫fragment and the login fragment.
‫So there is no change.
‫There is an error in the transactions.
‫Maybe.
‫Let me see.
‫And here we go.
‫You can see that I have missed this.
‫So login fragment.
‫Now if we run the application again it will give me the correct fragment.
‫So login page you can see the login fragment settings message and home page.
‫So congratulations guys.
‫We've learned how to create the navigation drawer application.