So now I want to let you know.
Another important point.
So let's actually get me to show you the structure of the project.
So let's actually click on The View tool windows and then project.
And as you can see here inside this it's folder if you have tame animals as you can see here in nature
to open this fall.
And you can see these tame animals.
And as you can see here all these images are dot PND.
Right.
The format of these images are thought PFG and Enceladus avoid animals.
As you can see we have also thought PAGG image is right but we have this image which is actually that
JP.
So because you want to actually interact with the name of these images from our Java code it's better
that all of them be actually of the same format.
So let's actually delete this image while and then underline animals dash ph underline punter that GGP.
OK so if you want to use this image make sure to change the format of this image and then you can actually
use it inside your own application.
But for this application because the format of all these images is actually data P in G.
It's better to all of them be of the same format.
So let's just select this image and then presently key on your keyboard and then click on OK.
So now that image is actually deleted.
And now that's actually the go inside our main activity the job file here.
And as you can see here.
Let's actually go inside these and create options menu.
As you can see here we have these on create options menu and we have this on options items selected.
OK so now let's run our project and see what happens.
So as you can see here our application is actually running on this emulator.
And now as you can see here at the top we have this action bar and if you want to click on this a certain
spot in here settings image as you can see.
Now we want to transition to their settings activity.
Right.
So as you can see here we have this image here right.
So this method uncreate options menu is going to actually put this item here inside this action bar.
So that's the job of this uncreate options menu.
So we have already dismissed it here with the default implementation.
So if it is OK we don't need to change the implementation of this method.
And now let's actually look at our method here.
On option items selected right on options items selected.
So now we need to actually change the Smurfette here.
We need to change the implementation of this method.
And as you can see here we have some comments here that says handle action but item clique's here the
action bar will automatically handle clicks on the home or part of button.
So long as you specify parent activity in Android manifest that XML.
Right.
So now let's actually delete these lines of code.
Here is implementation.
And now let's actually put our own implementations here.
So I'm going to pasting some lines of code here and then I'm going to explain to you what's going on
here.
So as you can see here these are two lines of code that I pasted here and in length 60 free as you can
see I created an instance of type intent.
I created an intent object here.
And the name of my instance is preference intent.
And then I put an assignment operator here as you can see I am actually creating a new instance of type
into it.
Right.
So new intent and as he has it here this actually accepts two arguments the constructor of this intense
class actually accepts two arguments but the first one is the context main activity that this comma
and the second argument is the activity that we want to transition to.
Which is actually setting's activity that class of we haven't still created this activity yet inside
our project.
So we need to create this activity now and actually look at our code here in our line 64 start activity
Prefect's activity our preference intent right.
So this means that whenever we use that actually clicks on these on the options I'd have selected so
far.
So now let me actually show you the emulator.
Now whenever the user clicks on this image here on this setting's image it's going to actually transition
to the settings activity that class start activity preferences intent.
Right.
So it's going to start.
The preference is going to start the settings activity here whenever the user clicks on these settings
image.
And here finally we are returning this value so returns super that an options item selected item.
OK so because this if it actually meets the return value of that bullion we need to really put this
thing in here return super so superior refers to the superclass right supertax on options items selected
and we passed this item as the argument of this misfit.
So now the create another activity inside our project.
So now let's create a view to Windows and then project beautiful windows project and then just now just
double click this job a folder here and then publicly turn this package here.
So now just click on File New and then click on activity and here choose basic activity right.
And for the name of your activity just type in here citizens
activity
right.
So the name of the activities setting's activity the lay out name is activity underline settings.
The title is setting's activity.
We don't want these settings activity to be the luncher activities.
Do not check to search box here.
And we also need a fragment for this activity so check the search box here use a fragment.
And here at the bottom it says if true the content will be affreightment right.
So when you check the box here it says if true the content to be affreightment.
So OK.
And now we also want to specify a hierarchical parent for these settings activity.
So just click on the spot in here.
Dot dot dot and choose this main activity here.
As you can see here the hierarchical hierarchical parent screen is going to be the main activity.
And here we can specify the package name which is OK by default what is OK and then click on finish.
So now as you can see here at the Android studio he provided us with our settings activity here.
And it also created a certain activity fragment for us.
Right.
And we have also these layouts here.
So we have activity Underland cities that exemplified.
We have content underlined settings that they will find which is going to only provide a fragment for
us as you can see Pracht fragment fragment Underland settings and we have also this fragment underline
settings here.
Right.
So this is our fragment Underland settings and now it's actually double click on this activity Underland
settings here.
Just click on this design tab here at the bottom selectees faluting action button and then press until
it key on your keyboard.
So now let's actually in say the main activity dojo a file here.
And now as you can see here the error is gone.
Right.
So let's actually go inside these settings activity as you can see here.
We have these lines of code that are related to the faluting action button.
So just select this block of code that is related to the fluting action button and then press on delete
key on your keyboard.
And now as you can see here we have this line of code here.
It says Get support action bar that said display home adds up enabled.
So what does this mean.
So now let me show you the emulator.
So here if I actually click on the settings image here as you can see this is our settings activity
right at the top.
You can see this actually this arrow here.
And if I click on it now it's going to actually move to this activity.
So that's the job of this line of code here.
Get support action bar.
So this is action.
But that said display home as OP enabled so it can actually provide this out here for us.
And whenever whenever I actually click on this arrow here as you can see we provided the value true
right.
So if you actually click on these are here now these can actually transition to this activity main activity.
Right.
So hopefully that makes sense.
And now it's actually double click on the settings activity.
Fragment here and now you can see that let's actually double click on this Tapio setting's activity
fragment or Jarba and now you can see this area there you can see that now.
This area is actually wider.
So we have this class savings activity fragment that extends from these Fleischman here as you can see.
So here we don't want to actually directly inherit from this fragment here.
So we want to actually inherit from the France fragment.
As you can see here now if we actually hold the comment on my keyboard and then click on this pre-feminist
fragment here.
So if you are using a Windows machine hold the control key on your keyboard and then click on this preference
for argument as you can see this preference fragment is actually inheriting from this fragment.
Right.
So now let me actually close this file.
And now as you can see here it is sitting actually with the fragment is inheriting from this a preference
fragment.
So now let me delete these lines of code here that are inside of this class.
And now I'm going to pasting some lines of code here and then I'm going to explain to you what's going
on here.
So as you can see here these are the lines of code that I pasted here.
So I actually write it the uncreate Smurfette.
And as you can see this if it actually accepts one argument which is of type Bondel saved instance in
St..
And here you are calling the uncreate of the superclass so stupid.
Uncreate saved instance state and here look at this line of code here which is really important at preferences
from resource.
So let me try to show you the structure of the project.
So just click on View tool windows and then project as you can see we have this ASML folder here.
Right inside this folder we have this ASML folder.
And as you can see we have the squeeze under the link preferences.
So if you actually provided this XML file in order to actually pro-white those settings options.
OK.
In order to actually create two cities items so that the user can actually change the format of the
text of the buttons or the user can actually change the background color of the keys.
So that's the job of this accident.
And if you want to use that FOI for our preferences.
So I actually created this on create Meffert here.
I actually override it this on create method inside the settings active defragment and then I actually
called the Smurfette at preferences from resource and then I pass this value to dismiss that are that
example so it refers to these five dot Q Is Underland preferences right.
So now we can actually get this example fight and show it to the user.
Right.
So let's let's actually go in the setting is activity or jobs.
So now you can see we have these lines of code here.
This is the classic settings activity that extends from app copy of compact activity and the override
that the uncreate Mfat here we called the super class version of this uncreate method and we passed
this argument to the Smurfette and then we called the Smurfette set content view are that lay out that
activity underlying settings right.
So let's actually DoubleClick and lay out what he had as you can see we have this activity under the
line settings here.
So we tried it here and then just double click on it takes time.
Here at the bottom you can see that these are the example codes and we have this include here.
These include tag layout and inside the double codes you can see that it says at sign out so it refers
to this lay out for the slash content.
Settings.
So it's actually it says that we want to include this content underlined settings on this activity underline
settings.
So we have this content Underland settings.
That is as you can see we have this fragment here.
So now it means that we want to use a fragment inside this XML file so that you use that.
Or that the program can actually interact with the fragment as you can see a fragment on the lengths
of things.
And now as you can see we have also this fragment underlined settings that we have these lines of code
here.
And as you can see we want to actually put the squeeze underline preferences that exemplified on this
fragment underline settings.
So inside the settings activity fragment you can see that we are right at the uncreate Merfeld right.
And then we called this Myford at preferences from resource are that ASML that these underline preferences.
So now let's actually build on our project and see what happens.