1
00:00:00,180 --> 00:00:07,560
So you need to also have an arty adapter and I need to put a pad of angle brackets in order to specify

2
00:00:07,560 --> 00:00:10,480
the type of values of this area here.

3
00:00:10,530 --> 00:00:15,600
So first let me tell you the job of this it up after this area that it is going to connect our data

4
00:00:15,620 --> 00:00:16,440
up stream.

5
00:00:16,470 --> 00:00:20,270
Added that we created in say these things that exemplified to this point.

6
00:00:20,400 --> 00:00:22,160
So that's the job of this area.

7
00:00:22,200 --> 00:00:25,590
So inside and goldbrick is just typing here char sequence.

8
00:00:25,590 --> 00:00:29,910
So now I can actually say the name is going to be it after semicolon.

9
00:00:30,250 --> 00:00:35,280
Now let's go inside this uncreate and initialize these variables so the first one is spinner assignment

10
00:00:35,280 --> 00:00:36,030
operator.

11
00:00:36,090 --> 00:00:38,700
So let's cast this object to a spinner object.

12
00:00:38,880 --> 00:00:44,160
Find your way id or the ID that spinner right semicolon.

13
00:00:44,550 --> 00:00:49,530
So now let's initialize our adapter.

14
00:00:49,540 --> 00:00:57,490
Actually our idea that her so that her assignment operator and hero can say every adapter that create

15
00:00:57,490 --> 00:01:03,010
from the source and insert Apprentice's as you can see if you need to pass some arguments the first

16
00:01:03,010 --> 00:01:04,700
one is going to be the context.

17
00:01:04,720 --> 00:01:08,300
So the context is always for this class is main activity right.

18
00:01:08,320 --> 00:01:10,250
Because we are inside the main activity class.

19
00:01:10,450 --> 00:01:15,910
So main activity that this and now we need to specify the second argument which is going to be the add

20
00:01:16,060 --> 00:01:19,270
resource to be created and are staring at a.

21
00:01:19,270 --> 00:01:20,970
Inside this thing that is in my file.

22
00:01:21,100 --> 00:01:27,110
So here I can see our DOT at a dot sports name.

23
00:01:27,220 --> 00:01:32,730
So this is the same and this is actually the exact arayed that we created in it seems that is a fight

24
00:01:33,260 --> 00:01:33,750
that they.

25
00:01:33,850 --> 00:01:34,680
Put a comma here.

26
00:01:34,690 --> 00:01:37,830
Let's create a new line so that you can see this value here.

27
00:01:38,170 --> 00:01:42,790
And the first argument is going to be a simple spinner list item.

28
00:01:42,790 --> 00:01:52,440
So here you can see Android dot dot dot actually lay out that spinner.

29
00:01:52,630 --> 00:01:58,350
Look at this one android that are that layer that simple spinner id..

30
00:01:58,460 --> 00:02:02,470
Choose this one and then put a semicolon at the end of your statement.

31
00:02:02,470 --> 00:02:04,490
So now we're initialising are great.

32
00:02:04,500 --> 00:02:09,850
So first we say that okay the context is main activity that this and that is said that the data is we

33
00:02:09,850 --> 00:02:10,780
get from this.

34
00:02:10,810 --> 00:02:13,050
All resources are added that the sports name.

35
00:02:13,240 --> 00:02:14,690
And what is this despina.

36
00:02:14,740 --> 00:02:19,880
This is the default spinner that we get from the Android Android that are that Liautaud simple spin

37
00:02:19,940 --> 00:02:20,460
like them.

38
00:02:20,560 --> 00:02:20,980
OK.

39
00:02:21,220 --> 00:02:30,180
So now we need to also specify a dropdown view resource so I can say adapter that sits drop down view

40
00:02:30,180 --> 00:02:30,850
resource.

41
00:02:30,860 --> 00:02:32,000
Choose this one.

42
00:02:32,280 --> 00:02:40,470
And now I can't say Android that are thought lay out that spinel just typing here spinner and the autocomplete

43
00:02:40,470 --> 00:02:46,580
feature is going to help you to choose this one simple spinner dropdown Eidem to this font.

44
00:02:46,890 --> 00:02:49,070
And now at the end of your statement put a semi-colon.

45
00:02:49,080 --> 00:02:54,700
So first we need to specify the symbol has been an item and it and then we need to specify the dropdown.

46
00:02:54,720 --> 00:02:56,150
And this is really important.

47
00:02:56,190 --> 00:03:05,690
So finally we can say spinner that sits at chapter spinnet the adapter adapter.

48
00:03:06,360 --> 00:03:06,720
OK.

49
00:03:06,810 --> 00:03:10,440
So visit the adapter of the spinner to that does it.

50
00:03:10,440 --> 00:03:12,510
After that you actually created here.

51
00:03:12,570 --> 00:03:16,150
So let's run our application now let's choose one of these devices.

52
00:03:16,170 --> 00:03:20,340
And let me show you the emulator.

53
00:03:20,430 --> 00:03:23,020
So now as you can see here our application is stunning.

54
00:03:23,250 --> 00:03:25,180
And it says Please select one sport.

55
00:03:25,200 --> 00:03:31,350
And if we actually click on this spinner if I click on this drop down here we can see that a list is

56
00:03:31,350 --> 00:03:31,930
shows up.

57
00:03:31,930 --> 00:03:34,740
It shows up here and we can select one of these sports.

58
00:03:34,740 --> 00:03:40,480
So for example I choose kickboxing and you can see this Kickboxing is selected or I can select one or

59
00:03:40,800 --> 00:03:42,100
two for example.

60
00:03:42,450 --> 00:03:45,430
And so what happens if we actually select one of them.

61
00:03:45,470 --> 00:03:51,470
You want to actually be notified when they use it actually selects one of these sports.

62
00:03:51,510 --> 00:03:55,550
So in that case I can actually create a select item list and are here.

63
00:03:55,560 --> 00:04:05,610
So here I can say spinner that select that sets select just set select So choose the one sit on item

64
00:04:05,610 --> 00:04:06,070
selected.

65
00:04:06,130 --> 00:04:07,290
Listen this is very important.

66
00:04:07,380 --> 00:04:13,710
And that person into your keyboard and instead Apprentice's just type in here new and just hold the

67
00:04:13,710 --> 00:04:14,650
shift key on your keyboard.

68
00:04:14,700 --> 00:04:17,320
And then just type in a.

69
00:04:17,640 --> 00:04:23,370
And now the autocomplete feature of Android studio is going to help you to choose this one an item selected

70
00:04:23,370 --> 00:04:23,850
listener.

71
00:04:23,850 --> 00:04:29,700
And in say the collaborators you can see dot dot dot to this one so that the Android studio is going

72
00:04:29,700 --> 00:04:35,940
to actually put the required codes they require if it's for you automatically.

73
00:04:35,940 --> 00:04:42,270
So here we have an anonymous in a class that actually conforms or implements this on item selected listener

74
00:04:42,270 --> 00:04:48,070
interface because that class is actually conforming or implementing this interface.

75
00:04:48,240 --> 00:04:52,850
That class must provide an implementation for these misfits that are inside of this on items like that

76
00:04:52,860 --> 00:04:53,590
interface.

77
00:04:53,610 --> 00:04:55,050
The first one is an item selected.

78
00:04:55,050 --> 00:05:01,020
So this Meffert is going to be called when they use it actually selects one of these sports for example

79
00:05:01,020 --> 00:05:02,650
boxing or bodybuilding.

80
00:05:02,880 --> 00:05:08,610
And if you have an addendum event when it actually is N-nothing selected So this is this it is called

81
00:05:08,610 --> 00:05:10,210
when nothing is selected.

82
00:05:10,230 --> 00:05:13,690
So we want to work with this method on items selected.

83
00:05:13,710 --> 00:05:17,550
So here I can create a toast message so toast that make text

84
00:05:20,700 --> 00:05:25,620
so inside the practice as the first argument I need to pass the context of main activity that this comma

85
00:05:26,040 --> 00:05:29,340
and the second argument is going to be the value that you want to show to the user.

86
00:05:29,520 --> 00:05:36,150
So you want to actually show to the user the actually the specific the specific sport that is actually

87
00:05:36,150 --> 00:05:37,110
selected.

88
00:05:37,110 --> 00:05:41,510
So this is actually you can see this item here this list here this is called the adapted view right.

89
00:05:41,520 --> 00:05:46,470
So we get this list as the after it beat you from this Meffert an item selected.

90
00:05:46,470 --> 00:05:51,970
So here I can say it after View got them at position.

91
00:05:52,210 --> 00:05:52,860
OK.

92
00:05:53,070 --> 00:05:56,210
I get them at position actually good item at position.

93
00:05:56,370 --> 00:06:00,510
So what is the position to position from this argument into.

94
00:06:00,570 --> 00:06:05,350
So the name is it's not meaningful enough to change this or to position.

95
00:06:05,940 --> 00:06:08,720
So you can see that we have this list right.

96
00:06:08,910 --> 00:06:11,630
So we can actually change this at least.

97
00:06:11,640 --> 00:06:13,830
Or we can change it to parent.

98
00:06:13,830 --> 00:06:15,220
So I can say this.

99
00:06:15,510 --> 00:06:18,130
So at least get them at position.

100
00:06:18,150 --> 00:06:22,560
So if you have this position here right position so it's going to give us the item at a specific position

101
00:06:22,560 --> 00:06:27,840
that is selected for example by the building and we can actually because we need to pass a single value

102
00:06:27,840 --> 00:06:32,700
to this method here as the second argument we need to convert it to a string value.

103
00:06:32,700 --> 00:06:36,690
So just put our Plus operator and then put two calls here come on.

104
00:06:36,960 --> 00:06:41,700
And as the first argument of need to specify the length of the message that they want to show to use

105
00:06:41,700 --> 00:06:42,830
that to such a statement here.

106
00:06:42,840 --> 00:06:44,380
In short.

107
00:06:44,630 --> 00:06:45,080
OK.

108
00:06:45,260 --> 00:06:50,130
Tostada then fourth and finally if you need to call the Schuurman for this object that be created here

109
00:06:50,470 --> 00:06:51,760
show that show.

110
00:06:52,110 --> 00:06:53,190
Let's run an application.

111
00:06:53,190 --> 00:06:55,090
Now let me show you the emulator.

112
00:06:56,360 --> 00:07:00,490
So now as you can see here are actually our application is running.

113
00:07:00,760 --> 00:07:07,820
And now you can you actually saw that football toss the message here because the football is now selected

114
00:07:07,910 --> 00:07:10,020
as the first and she devalue.

115
00:07:10,160 --> 00:07:16,410
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.

116
00:07:16,730 --> 00:07:18,210
And now it says two.

117
00:07:18,260 --> 00:07:21,510
So that's how spinner works in and right.

118
00:07:21,770 --> 00:07:26,240
So if you have any questions about spinner in Android please answer this question in the course and

119
00:07:26,240 --> 00:07:28,340
then I do my best to answer all of your questions.

120
00:07:28,340 --> 00:07:29,580
Thank you very much for watching.

121
00:07:29,690 --> 00:07:31,130
And I'm sitting next to Tauriel.

