So you need to also have an arty adapter and I need to put a pad of angle brackets in order to specify
the type of values of this area here.
So first let me tell you the job of this it up after this area that it is going to connect our data
up stream.
Added that we created in say these things that exemplified to this point.
So that's the job of this area.
So inside and goldbrick is just typing here char sequence.
So now I can actually say the name is going to be it after semicolon.
Now let's go inside this uncreate and initialize these variables so the first one is spinner assignment
operator.
So let's cast this object to a spinner object.
Find your way id or the ID that spinner right semicolon.
So now let's initialize our adapter.
Actually our idea that her so that her assignment operator and hero can say every adapter that create
from the source and insert Apprentice's as you can see if you need to pass some arguments the first
one is going to be the context.
So the context is always for this class is main activity right.
Because we are inside the main activity class.
So main activity that this and now we need to specify the second argument which is going to be the add
resource to be created and are staring at a.
Inside this thing that is in my file.
So here I can see our DOT at a dot sports name.
So this is the same and this is actually the exact arayed that we created in it seems that is a fight
that they.
Put a comma here.
Let's create a new line so that you can see this value here.
And the first argument is going to be a simple spinner list item.
So here you can see Android dot dot dot actually lay out that spinner.
Look at this one android that are that layer that simple spinner id..
Choose this one and then put a semicolon at the end of your statement.
So now we're initialising are great.
So first we say that okay the context is main activity that this and that is said that the data is we
get from this.
All resources are added that the sports name.
And what is this despina.
This is the default spinner that we get from the Android Android that are that Liautaud simple spin
like them.
OK.
So now we need to also specify a dropdown view resource so I can say adapter that sits drop down view
resource.
Choose this one.
And now I can't say Android that are thought lay out that spinel just typing here spinner and the autocomplete
feature is going to help you to choose this one simple spinner dropdown Eidem to this font.
And now at the end of your statement put a semi-colon.
So first we need to specify the symbol has been an item and it and then we need to specify the dropdown.
And this is really important.
So finally we can say spinner that sits at chapter spinnet the adapter adapter.
OK.
So visit the adapter of the spinner to that does it.
After that you actually created here.
So let's run our application now let's choose one of these devices.
And let me show you the emulator.
So now as you can see here our application is stunning.
And it says Please select one sport.
And if we actually click on this spinner if I click on this drop down here we can see that a list is
shows up.
It shows up here and we can select one of these sports.
So for example I choose kickboxing and you can see this Kickboxing is selected or I can select one or
two for example.
And so what happens if we actually select one of them.
You want to actually be notified when they use it actually selects one of these sports.
So in that case I can actually create a select item list and are here.
So here I can say spinner that select that sets select just set select So choose the one sit on item
selected.
Listen this is very important.
And that person into your keyboard and instead Apprentice's just type in here new and just hold the
shift key on your keyboard.
And then just type in a.
And now the autocomplete feature of Android studio is going to help you to choose this one an item selected
listener.
And in say the collaborators you can see dot dot dot to this one so that the Android studio is going
to actually put the required codes they require if it's for you automatically.
So here we have an anonymous in a class that actually conforms or implements this on item selected listener
interface because that class is actually conforming or implementing this interface.
That class must provide an implementation for these misfits that are inside of this on items like that
interface.
The first one is an item selected.
So this Meffert is going to be called when they use it actually selects one of these sports for example
boxing or bodybuilding.
And if you have an addendum event when it actually is N-nothing selected So this is this it is called
when nothing is selected.
So we want to work with this method on items selected.
So here I can create a toast message so toast that make text
so inside the practice as the first argument I need to pass the context of main activity that this comma
and the second argument is going to be the value that you want to show to the user.
So you want to actually show to the user the actually the specific the specific sport that is actually
selected.
So this is actually you can see this item here this list here this is called the adapted view right.
So we get this list as the after it beat you from this Meffert an item selected.
So here I can say it after View got them at position.
OK.
I get them at position actually good item at position.
So what is the position to position from this argument into.
So the name is it's not meaningful enough to change this or to position.
So you can see that we have this list right.
So we can actually change this at least.
Or we can change it to parent.
So I can say this.
So at least get them at position.
So if you have this position here right position so it's going to give us the item at a specific position
that is selected for example by the building and we can actually because we need to pass a single value
to this method here as the second argument we need to convert it to a string value.
So just put our Plus operator and then put two calls here come on.
And as the first argument of need to specify the length of the message that they want to show to use
that to such a statement here.
In short.
OK.
Tostada then fourth and finally if you need to call the Schuurman for this object that be created here
show that show.
Let's run an application.
Now let me show you the emulator.
So now as you can see here are actually our application is running.
And now you can you actually saw that football toss the message here because the football is now selected
as the first and she devalue.
Let's change this one to take one two and you can see it just take one two or I can change it to judo.
And now it says two.
So that's how spinner works in and right.
So if you have any questions about spinner in Android please answer this question in the course and
then I do my best to answer all of your questions.
Thank you very much for watching.
And I'm sitting next to Tauriel.