So here as you can see our application is running on the simulator but now I want to actually create
a menu for my application here inside this action.
But I want to create a menu.
So now in my project structure here I need to actually click on these raids folder here.
Right click on it.
And then click on Android early source directory as you can see here.
Android resource directory and for the name just type in here just for the resource type just select
menu OK and then click on OK as you can see the directory name is menu.
There is sort of the resource type menu and the source said is me OK.
And then click on OK here.
So as you can see here I have this menu of folder this our menu directory inside my race for that right.
So just right click on these menu here.
And a new.
And then click on menu resource file.
So just for the name of our menu file which is going to be an XML file just type in here menu underly
made.
And then click on OK.
So inside this menu directory I have this menu underline the XML file here.
So as you can see here this is that file.
So now I want to actually create an item.
So just open a type here item and for the title just type in here settings and then I want to actually
give an ID to this item.
So just type in here ID as you can see here and then press enter key to select this idea here.
And in order to create an ID unit to actually used this here at sign Plus Id This is very important
at sign.
Plus Id just use this piece of code here and then press that into the general keyboard.
So now I can actually specify an ID for my item here.
So for the ID just type in here settings OK and then now let's actually close this item here by just
using a closing tag here.
Now let's run our project and see what happens.
So as you can see here now our application is running on the simulator and still we can't see this the
item menu here.
OK.
So we need to go back inside our main activity the java file here and we need to actually overwrite
some methods.
The first one is on create options menu.
And as you can see here we have this method.
So the autocomplete feature of the Android studio is helping me to find Mefford.
So just a selected and then person enter key on your keyboard.
So as you can see here this is that Meffert and the second half of any two over right here is actually
an options item selected as you can see here just select it and press on entelechy on your keyboard.
So now inside this uncreate options menu Meffert as you can see we have this line of code here.
Just select this line of code and then press until it key on your keyboard.
So now I want to actually put in my own logic here.
So now I want to actually inflate the menu on my action but so as you can see here in our emulator we
have this action.
But here and I want to actually inflate the menu on this action but here.
So in order to do that I can just type in here get menu inflator does inflate and here you need to actually
pass two arguments.
The first one is of type menu resource file.
So as you can see here we have this our menu resource file here in our project structure inside this
race folder menu that underline minute example.
So here I can just type in our start menu that menu underline main here and then press on Enter key
on your keyboard.
So this is the first argument.
The second one is the menu object that you actually receive as an argument from this on create options
menu method.
So here I can just type in menu.
So now because this if it actually returns a boolean value we need to return true in order to inflate
this menu here on our action bar.
So here I can just type in return true and then put a semicolon at the end of your statement.
So now let's actually run our project and see what happens.
So as you can see here now our application is running on this emulator here and here at the top.
Inside this action but here we can see this menu.
And if I selected I can see the settings here.
OK.
So this is the item that they actually created inside this menu and the line made that examine the title
the settings and the ID's settings right.
So let's go back into our main activity Dodgeville file here.
And I want to actually do something.
When the user clicks on these settings here.
OK.
So again let's actually go inside this on options item selected here and here as you can see this before
it again returns a boolean value.
So it is actually enough to really turn the supervision of the Smurfette superdad on options item selected
item.
OK.
So now before this line of code here we can put our own logic here.
First of all I want to actually get the ID of the item that you've selected.
So inside this menu under the nine minute segment as you can see I have this item and I actually provided
an ID for this item sitting right.
So here inside is an options item selected.
I can get that ID.
So in order to get the ID I can create an entire idea about it and the name of my value is going to
be ID.
Assignment operator.
So as you can see here we actually received this item.
This menu item as an argument from an optional item selected Nefert.
So I can just refer to the name of this argument item that gets item ID.
So now I can actually access the ID of my item.
OK.
So here I can actually create an if statement or actually a switch statement.
And here I can switch between the IDs of the items that are inside of this menu that menu that main
menu and the alignment that means that example as you can see here we have only one item here.
And the 80s settings so I can just type in switch ID.
OK.
And then I need to open and close this switch block here and then I can create an ok statement.
Case r that I'd already thought settings as you can see here just select it and then person enter key
on your keyboard and then put a colon here and then create a break statement here.
So now for this break case statement I can't say that I can actually create an intent object here.
So what I want to do I want to actually move from this activity to the preferences example that I am
going to create.
Now first of all let's actually create that example of file and then we're going to actually continue
coding inside this case statement.
So now in our project structure let's actually select this arrays folder here as you can see right click
on it and then click on new and then click on Android resource wide.
OK.
And for the name of our file just type in here pretty for preferences underline file that exit mail.
OK.
And the resource type just type in Excel like this XML here for the resource type and the root element
is going to be pretty friends screen and the source said is main and the directory name is XML.
OK.
So it's going to actually create a directory for us and then it's going to actually also create this
XML file.
Preferences underline find that example.
OK so let's click on OK here.
An insight Isarel falter I have this XML directory.
As you can see an insight is ASML directory.
I have these preferences underlined file that ASML here.
OK so now let's to go inside these preferences underline find that example here.
And now let's actually put some lines of code here.
So this is going to be the settings activity the settings a layout of our application.
So when the user clicks on these settings here as you can see when the user clicks on the settings here
is they're going to actually go to this XML file and then they can actually interact with that XML file
and specify some actually preferences for their application for the application.
Right.
So now I went actually pasting some lines of code here and then I'm going to explain to you what's going
on here.
So now as you can see here these are the lines of code that I actually pasted here inside these preferences
underline file that example he had as you can see inside these preferences preferences are preference.
Screen tag here as you can see I have this preference category here as you can see.
So I have these lines of code.
So now I'm gonna actually explain to you what's going on here.
As you can see here in line 6 as you can see I created this tag here preference category.
And I gave a title to this category.
And as you can see here the title is text number 1 settings.
OK.
So here I want to specify the settings for the text number of on.
So as you can see here in our emulator I have this takes number one here.
OK.
So as you can see I have these settings and I want to provide some settings for this text number one.
So let's see what that is going to be the settings.
The first item as you can see here inside this preference category here.
I have this checkbox preference so I'm going to actually create a checkbox for this.
Takes one here checkbox preference.
And as you can see here these are the attributes that they actually assigned for this checkbox preference.
So first of all I actually gave a key to this checkbox preference.
The keys checkbox underline font.
The line number of underlined text 1.
So now you can actually understand that you want to actually specify the font for my text one here.
OK.
When I go into the settings XML file I want to specify the font of this text one here for example.
So this is going to be the key.
So help us to actually this helps us to use this key in our Java file and interact with this checkbox
preference.
So this is very important that you actually give a key to your checkbox preference.
And here I gave a title to my a checkbox free France and the title is traunch 5.
OK so this is going to be the name of the format that the user can select for.
This takes one here.
This is takes number one.
And as you can see here I have this summary.
So the Samadi is going to be a string value that I will be showing you in a minute.
So it's going to give you a description about this specific tick box preference the summary.
And we have this default value.
So default the default value is going to be the default itself.
Chunk 5 that or T.F..
So as you can see here in our project structure here in our assets folder I have this Faunce directory.
And as you can see here I have this and chaunced 5 that Auty ATF.
So it is very important that the name that you actually put here for this default value must be the
same as this name.
Here inside this Faunce directory.
So here as you can see I am actually closing this tag here this checkbox preference.
And again here I actually created another checkbox preference.