Hello there.
I'm gonna be gone.
And welcome back.
Demand what you do realize in today's with you.
We'll be talking about navigation door.
So what is the navigation door.
It is a sliding menu which appears on your Android screen with the hamburger icon in your action bar.
So let's create a new project and get started.
Let's call the project a navigation draw tutorial or draw tutorial
draw tutorial that's on the next button.
Again we're going to keep an eye on him as he gets 15 y so that we can run our application on almost
hundred percent of the devices running Android in the world.
Let's hit the next button
let's start with an empty activity.
Let's call our first of to ideas may not do lots of the finish button
well understood that's building a project so let's wait.
So the bottlenecks built and it's ready to go.
So let's get started.
So coming to the loud fight for us.
Well let's get rid of this concern loud and so this constant loud we'll be using a drone allowed on
to use that.
We'll after our dependency on the grid.
So let's do that first.
So we load scripts application grader let's order dependency here.
So implementation calling not Android not supposed design.
And the vision which is twenty six point one point zero let's sing the greater Well the gradient think
on our design support libraries ready to use.
So let's disclose this file looks closed us.
So coming back to our main example.
So let's change this to draw out.
Let's give it an IDC draw layout.
OK.
Let's just have the navigation with you with say 270 DP unsafe height much better and so it's the navigation
view which gives you that left column which slides in and out.
OK.
And this requires a menu file to populate the draw menu.
So let's create a menu file.
So coming to resources let's create a menu directory.
So a new resource directory let's call it menu.
Okay.
So coming here to the directory lets other new file a new menu resource file.
So let's call it a draw menu.
That's a low key button switch to the takes mode.
Let's disclose this.
Let's order first menu item that's the title.
And to add that I don't mean it's strange.
Which we need to define in string for example.
So coming to values on string example let's create the string for our menu item.
So let's call it a stay your home
similarly let's add one more.
So let's say a star about us and let's define the string us about us.
Okay.
Coming back to the menu eczema.
Let's define that ideal here.
So as your home let's define an idea say menu home let's define another menu item
let's go by the title say SDR about us.
Sorry it's about to use OK.
Coming back to the menu not example.
So about of us let's provided with an idea say menu about us.
OK.
So coming back to main example let's provide this menu file here.
So which is draw our menu.
OK.
We need to define the gravity which tells the system from which direction this drawing needs to slide.
So let's define that so loud gravity let's say.
OK.
So Android no gravity let's say.
Start
okay I guess we'll get ready to go.
Let's have a look at the preview.
Let's bring in the site.
I'm going to select here.
You can see there's an outline of a hue.
So this is our draw.
So let's close the preview coming to our main activity on Java.
We need in stands of our draw layout.
So let's create dot.
So private draw out.
Let's call a draw layout.
Let's initialize it.
So draw loud as a goal to find you but idea or idea and draw out.
Let's also create an instance for navigation view.
Let's create an idea here.
So the let's call it now draw
gain and just copy to so private navigation view.
Let's call it now draw.
Let's initialize it.
So not draw is a goal to find new but idea dot idea and not draw.
Okay.
Both of our views are declared and initialize.
So far what we've achieved is we've created a navigation draw.
Now let's buy that hamburger.
OK.
So coming back to our main dot example let's provide a toolbar here.
So toolbar with much parent hide.
Are action bar.
Sighs OK
let's provide a background see color primary door.
Let's provide a style.
So Team overlay up combat action bar.
OK.
Or toolbar is ready.
Let's go I did with an I.D..
So I.D. toolbar and we need to change the theme of our obligation so let's go to the manifest.
So application manifest.
So as you can see teams let's change that.
So team up combat light no action bar.
So we've removed the default action bar and we've added our own.
So let's disclose this manifest coming to the main activity.
Let's create an instance of this toolbar so toolbar let's call it doable so find a but I.D. dot I.D.
on board
OK.
So it's probably some greeting thing to shoot.
Let's set the support action bar so set support action button.
Let's go wider toolbar OK on it sees required support with seven toolbar.
So it's just some import issues.
So let's delete this and now all and import glass.
And that's important support with event.
OK.
Now let's define some more things.
So if gets a bolt action bar is not equal to no.
We're just ticking if our action bar is present.
So gets a bolt action bar set home is enabled through and gets a bolt action bar set up in the gate
too.
So here we are to provide that hamburger icon.
So let's create that.
So coming to resources right click new reactor asset.
Let's click on this icon
let's search for menu.
This one looks good.
OK well let's hit the next button.
OK.
Let's just change this names.
Do I see menu next on finish.
So let's close this.
Now we can just use the drivable I see menu.
Well our hamburger is ready so let's build our application and see
well.
Applications running so let's have a look.
Well our drawers should definitely.
But don't click is not working.
The drawers sliding in but everything's blue why.
So let's have a look.
OK.
So for the container layout Alexis Robert and Alina allow so much parent March parent orientation say
vertical Let's drop these both things in June.
OK now let's build it again.
Well applications running so let's have a look.
Now everything looks good.
If we swipe and we can see our draw.
Well but this is not working so let's handle this on click.
So because this is a menu so on options item selected should do to switch.
I do not get item I.D. case.
So the idea for this is Android are I.D. at home.
So what we want is whenever the user hits this button we should open the door so draw out that open
draw let's draw the gravity which was gravity dot start.
OK.
And let's just return true because this function requires a boolean result.
OK.
Let's put a default case.
Let's just return this Hugh Okay we're good to go.
So let's move the application again.
Okay.
Now if I click you my door is open and if I click you and nothing is happening so let's handle these
on clicks.
So coming back to our yellow file.
So now draw dot set navigation items like this node new navigation items like this no again let's create
a switch so item get item idea.
So we're just handling go and click on the basis of item items.
So let's just call this case let through either case.
So if you remember let's come back to this monitor.
Example The idea for a menu items were many Roman menu about.
So let's use these here.
So case ordered i.e. menu home.
Let's create a toast here.
So those that make decks.
That's really the context so we're not divided on this.
Let's divide the message so.
Home plate.
Let's try the duration.
So short and let's call the show function OK let's return boolean values so let's say true.
Similarly let's define it for about us.
So ordered i.e. not a menu about us.
Let's create another toast.
So make text through the context so mean activity like this.
Let's provide the message so
about us clicked.
Let's do the duration.
So in short.
Okay.
Let's roll the default case as well.
So default return false.
Okay.
So we've handled complex let's run our application again both the applications running so let's have
a look.
Let's click here.
Let's click on home and say home click.
Let's try.
About us.
This is about us clicked.
Well the only thing missing here is a header so that's that as well.
So let's create allowed for header.
So going to resources layout right click new resource file.
So let's call it a draw header.
That's the key button.
So that small and close this.
Let's get rid of this constraint layout let's call it to a linear layout.
Let's go out with an orientation C vertical.
That's what I did with a background color.
Say primary dark.
That's provided with a TextView with match variant or with wrap content and high drop content.
I'll just tell you why I did that.
So Ida we don't need an idea here for now.
Let's provide a string for this.
So strings dot example.
So SDR welcome.
So let's pull the string welcome view you coming back to the header load example let's throw the welcome
string here.
So string welcome.
Okay let's change the color so text color say Android color white and let's let's check the preview.
So as you can see the welcome is on the top.
So let's bring it in the center so gravity center and let's change the height to say on grid DP.
This looks good.
So let's close this on coming to the main for example let's throw away the header layout here.
So that allowed the name of the head allowed us draw header.
Well everything's all set so let's run our application and see
well the applications running so let's have a look.
OK.
Well the header is also here.
Well that's all for navigation draw folks.
If you have any issues any doubts feel free.
Robert Coleman and we'll go through it again.
And bye.