 Hi. In this video, I want to show you one more thing that I did not do in lecture. So if you open your Java file inside the main activity, what I showed you here is how you set up the event listener. So let's go over here, turn this off. Okay, so this is how you set up the event listener for the navigation review. So you can do it this way using the inner class like this. It's quite common as well. And we perform everything here in this block of code. It's kind of hard to see because it's kind of big here, but let me resize my screen. My code, you can see that it's inside, everything's inside this function called uncreated. You can do it this way, which is perfectly fine. But if your code gets pretty bloated, it gets pretty bulky, then what you can do is you can break this out. This whole thing here to a function, right? Of course, there are lots of ways to do it, but one way is the way we did. So let me go and refactor my code and let me copy this, where I can just cut this out and put into a function down here. And we'll call it public. We're going to return something back. Okay, this function returns requires a Boolean. So let me make it a little bit bigger. That means it needs to return a Boolean and we'll call it onSelected. This is just my own function, okay? Item, like that. And then I'll paste everything right back in here, right? So now we need to pass in the item so we can use over here. So therefore, this is the item over here, this main menu. When I call the function onSelectedItem, I need to pass in the item to that function. So therefore in here, I need the menu item. And it needs to return a Boolean value. So therefore, this function is going to be called with the return statement, right? Because in the end, I'm going to return a true, or whatever it's being returned here for code activity, it's going to return something else. So now you can see that my code is a little bit cleaner inside here. I still, you know, use the inner class to perform this operation, but my code is now much cleaner and I pass it on to an external function and I can control that much better than the other way around. And if I run this now, it should still work just like before. Okay, so hopefully then nothing breaks. There we go. Okay, so there we go. Yeah, so that's what I wanted to show you. One way is like that. Another way where you can do is you can implement this interface. This is an interface. It's a function, but it's part of the interface. So instead of doing this way, you can turn all this off. Let me do this way. And up here in the function and the class, I'm going to implement the navigation view dot on navigation item selected listener. If you implement this listener, then you go into implement this function called on navigation item selected, right? So just click on that, say OK. And here we are down here is the function you need to implement. Again, just remove all this JetBrains non-nose stuff. So then this part inside here is exactly same as this. Or one idea earlier. So what I mean is I can copy all this, everything here, and move it down to this function down here, and then replace everything here. All right. So there we go. So now if that's the case, then I don't need this. This is no longer needed. And let me hide this part. I don't need all this. And my drawer is already in the global space. OK, good. So now I just have to activate that function. So over here, so instead of going to set navigation and you do the whole thing here, I'm still going to need to load this. But I'm going to pass into this function, this entire function, the contacts. So here you would say navigationView.setNavigationListener and you pass here just this. And you let the interface handles all these implementations. So this function is going to be called, pass this to the interface, and you're going to implement this function down here, and everything here is the same as before. OK, so that's just, again, a third way how you do it. Again, if I run this now, it should still work just like before. OK, you can see nothing breaks. And there you go. All right. And then last but not least, I will show you anyway, is that when you go to the activity, you want, notice I don't have the hamburger menu here because I choose not to do it. You can if you want to, you can just add it on. But I'm going to show the back button using this before, right? You go back to the button. And you do that by going to your manifest file up here. And you need to choose the parent class of this one here. So the location activity, the parent will be just a dot main activity and the same for the contact. OK, so those are those are the ones. And if you want to change the title, instead of says my favorite fragment here, you add a label. So you put here label would be, you know, this is the, what is, what is this? This is the contact, OK? Contact us. And up here is the location. So you put here again, the label will be our location. OK, so you turn that on in the Android manifest, then in your code the contact location here, you to add the action bar. Turn on action bar. So it'll be just action bar. And then again, this action bar equals, we're going to get the support, the action bar. Then action bar dot set display display home as up and enable. But you pass in true. And that's it. This will turn the, you know, back icon or home icon back to home or back to the previous page. OK, so I'm going to copy this and paste it over to the other activity as well. And so both of those should now have that back arrow and run your code again. So here we go. If I go to the location or contact us, you see I changed the title as well as the arrow going back to the previous activity. Okay.