‫Let's add that data to the spinners.
‫We start from the from spinner dot set on item selected listener.
‫New adapter view on item selected listener.
‫So we are adding some functionality to this spinner and getting the data from the.
‫String array culled from languages.
‫How to add this?
‫Start from language code.
‫Equal get language.
‫Get the get language
‫code which is an a method that we are going to create.
‫So create the method inside the main activity.
‫So I have created this.
‫Method here and its returning type is an integer.
‫So we are going to pass as string, we return it as an end.
‫So what we need to to pass as string called language.
‫And we return the language code.
‫So language.
‫Code equal to zero.
‫We start by.
‫So the language that you start by here so English, Afrikaans, Arabic, Belarusian, Bengali, Catalan
‫and Hindi.
‫And although you can add whatever you want from the languages here, but you need to add the code exactly
‫like that.
‫We are going to see in this method.
‫So please concentrate with me, guys.
‫Switch language.
‫If the user pass the English.
‫So the first case is an English.
‫We start by returning and setting the language code to Firebase Translate language.
‫Or you can start by translate
‫language dot e and.
‫Okay.
‫Break.
‫But if we look closer, required type is an end provided the string in that new newest documentation
‫of the firebase translate language and locate it returns not a and not an integer.
‫It returns a string.
‫So we need to change the data that we have provided here, that language code.
‫And now we need to return the language code.
‫The returning type should be a string, not an integer.
‫And.
‫Here.
‫We will initialize it as an empty string.
‫So this is the first case.
‫Now, let's continue with the other cases from here.
‫Case.
‫In case, it's called Africa's Afrikaans.
‫The language code.
‫Equal to translate language dot f recants break.
‫I will stop the video, post the video, and continue with the other languages in order to save the
‫time.
‫So I have added these languages and their codes.
‫The default will be an empty string.
‫This is the method that will returns for us.
‫The language code of the past parameter of the language.
‫I can remove this initialization and would be good.
‫Now let's continue with our method here and I will pass the parameter from the selected from the selected
‫item inside the first spinner, which is the from spinner.
‫So from languages and I will pass the position of the.
‫There is an error required type is an integer when provided as a string.
‫So we need to change the field from language type to string.
‫I will change here then the string and we can remove the zero.
‫Here.
‫We have finished this.
‫From spinach.
‫The second thing I need to make is the array adapter that will allow us to to bind the data from the
‫array from languages and display it into the spinner and allow us to make the action of selecting the
‫data from this spinner.
‫So array adapter from adapter equal to you, array adapter and this and what is the, the layout that
‫we need to to pass and display it as a custom, which is called the spinner item we have created before
‫in the previous videos and from languages from adapter dot set to drop down a few resource android dot
‫layout.
‫Or are they out.
‫The simple drop down height and from spinner dot set adapter to from adapter.
‫This is how we make the spinner works.
‫Fine.
‫We can make it inside a method.
‫We can move this bunch of code into a method.
‫You can create it or I can comment like this.
‫Spinner number one.
‫Now, in the same way we will make the spinner.
‫Number two, we start from to spinner dot set on item selected listener new adapter review on item selected
‫the listener in the same way two language code equal to get language code and two language languages
‫array and I will select the I position.
‫I will.
‫Collapse this and I will add the array adapter.
‫Ray adapter.
‫Don't.
‫Or to adapter equal to new.
‫New early adapter.
‫And passed this.
‫There are dot layout, earth spinner item and two languages.
‫So I go to new line and to language.
‫Do adapter dot set.
‫Drop down.
‫Set.
‫Drop down.
‫View resource android dot or dot.
‫Layout dot.
‫It's simple drop down
‫tool spinner dot set adapter and to adapter.
‫In this way, we have finished creating our spinners.