Hey there.
So let's continue the development of our Olympus club application.
We need to initialize our subpoena that we created.
We already worked with a subpoena when creating the music shop app and you probably remember that we
used the array adopter that we need to do the same here.
That is we must create a private area adopter variable
let's call it spin adopter
and we also need to create an array list which we will put in this adopt
subpoena array list.
I will call you it and further in the own create method or we can initialize this adapter first.
We need to create a new all released object and put the necessary elements into it.
That is with the right subpoena.
I read at least assign new array list and then add the elements to it spin the ever a list at we will
add the strings that we will be there the first as I said will be unknown gender by default.
It will be set the next man.
And the third option will be female Gen.
Next we need to initialize the variables peanut adopt a new array adapter and here past the context
first.
Next layout element Android our layout
huh.
Yeah.
Great Mistake on layout simple spinner item
and the third parameter.
This is all really spinner.
I write this.
Let me move it to another line so that you can see better.
And then we need to create for our speed the adopter said drop down your resource
view of each spinner element.
Again we specify Android are layout and simple spinner.
Dropdown item
in this way.
Well basically everything is initialized and now we can use all the spinner.
Let's try to do this around the application
go to the second activity.
So nothing is displayed in this.
A while.
Yes of course.
Hi I forgot to install this adapter for a spinner.
I just will write Jenny's subpoena said adopt and pass the subpoena adopted and now restart
soul.
You see the first option immediately appears unknown and then we can choose male and female.
This approach which I already showed you in music shop is called the dynamic method.
Why.
Because we can in this area released in the program in the application.
Some way in the future in another place.
Add elements through the array list so we can make any number of elements options of this spinner.
But there is another way.
Static void.
That is the way we determine the structure of our subpoena and the number of elements in it immediately.
It is fixed as in our case will only have three options always unknown male and female.
There can be no other.
Therefore we can do it in a different way.
Well let me assure you that you know it to to do this.
We need to create values in their values new resource file arrays and then here.
Right.
String array.
Specify name array gender.
Here it is not a load Dash.
Right.
On the score on the score.
And we write here.
Item The first unknown
copy paste to more the second male and the third female.
So now we created our array and now we can use it.
That is a we no longer need their release.
We remove it since we will use the array from the resources to remove these code 2 and when creating
the spinner adapter we use a different initialization.
We do not create a new object using their guns using the constructor but use the static method of the
class array adapter create from resource.
And here we are again past the context parameter every pass from our error is with this name array gender.
Now we simply specify R here because it is from our resources from the application resources are array
Ray gender.
And here again we specify resources to fund do it and draw it out.
This is the common resources layout simple spinner item
and now we have such quote no such units initialization and the rest of the code does not change highlights
or restored the application
and we see everything turns out exactly the same.
Now we need to corner the spinner with logic so that when choosing a specific element our variable which
we create agenda a certain value is set to eat.