Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
1
00:00:00,840 --> 00:00:05,250
At the end of the last section, we added in this floating action, but button which it right here,
2
00:00:05,430 --> 00:00:06,840
what if we hover over it?
3
00:00:06,840 --> 00:00:10,920
You'll see that there's a little bit of a warning that says the parameter on press is required.
4
00:00:11,580 --> 00:00:15,780
Let's take a look at the documentation around floating action button and see if we can't get a better
5
00:00:15,780 --> 00:00:16,980
idea of what's going on.
6
00:00:17,920 --> 00:00:22,630
So I'm going to go back over to my letter documentation, and again, on the top right hand side, I'll
7
00:00:22,630 --> 00:00:25,930
look up floating action button.
8
00:00:28,460 --> 00:00:32,750
And then once I pull up the documentation for that class, I'll scroll down to the constructor.
9
00:00:34,100 --> 00:00:39,740
OK, so here's the floating action button constructor inside the list of all these named parameters.
10
00:00:39,770 --> 00:00:44,240
You'll notice that there's one called on press right here and that's exactly what that warning message
11
00:00:44,240 --> 00:00:45,200
was complaining about.
12
00:00:45,860 --> 00:00:51,080
Now, right in front of Unpressed, you'll notice that there's this thing called at required.
13
00:00:51,770 --> 00:00:52,400
At required.
14
00:00:52,400 --> 00:00:58,310
Right here, as you might guess, means that we are required to pass in some value for this unpressed
15
00:00:58,310 --> 00:00:58,910
property.
16
00:00:59,390 --> 00:01:05,209
So if we create a action floating action button, we have to pass in a value for unpressed.
17
00:01:05,660 --> 00:01:10,130
So let's first just add in that name property and then we'll figure out what value we're going to pass
18
00:01:10,130 --> 00:01:10,670
into it.
19
00:01:12,320 --> 00:01:19,010
Back inside my code editor, I'm going to expand the floating action button, I'll add in unpressed.
20
00:01:20,420 --> 00:01:21,810
And then we'll just leave it right there.
21
00:01:21,830 --> 00:01:25,760
We're going to go back over to the documentation very quickly and figure out what we need to assign
22
00:01:25,760 --> 00:01:26,270
to this.
23
00:01:27,390 --> 00:01:34,110
OK, so back over here, that type of unpressed says that it is supposed to be a void callback or I
24
00:01:34,110 --> 00:01:36,420
don't know about you, but that sounds kind of scary.
25
00:01:36,860 --> 00:01:38,840
Let me give it to you in very simple English.
26
00:01:39,330 --> 00:01:44,340
Essentially, we have to pass in a function to this unpressed property.
27
00:01:44,760 --> 00:01:49,040
Any time the user presses on the button, the function that we pass in will be invoked.
28
00:01:49,740 --> 00:01:55,770
So all we have to do over here for unpressed is assign a function or create a function.
29
00:01:56,320 --> 00:02:01,860
So to create a function right here, I'll put my set of parentheses and then my curly braces like so.
30
00:02:03,310 --> 00:02:09,250
So any time a user presses this button, this function right here is going to be executed to test out
31
00:02:09,250 --> 00:02:13,050
that behavior, let's add in a print statement inside of it.
32
00:02:13,270 --> 00:02:16,330
So let's say print high there like so.
33
00:02:17,590 --> 00:02:22,810
And then don't forget, we need to add a comma at the end of the function, otherwise the entire functionally
34
00:02:22,810 --> 00:02:24,010
collapsed automatically.
35
00:02:24,680 --> 00:02:26,230
It's going to put a comma right there.
36
00:02:27,120 --> 00:02:32,520
So let's now save this, we'll try refreshing our emulator again and seeing if we can't get this print
37
00:02:32,550 --> 00:02:35,460
message to display if we tap on that button.
38
00:02:38,360 --> 00:02:42,800
So I'll pull up in my terminal, I'll hit Shift Oregon to reload our application.
39
00:02:47,380 --> 00:02:52,420
Now I see a button on the bottom right hand side, it looks like the button is just a very plain blue
40
00:02:52,420 --> 00:02:56,930
button and it's not currently showing that kind of plus inside of it that we had wanted.
41
00:02:56,980 --> 00:02:59,170
So we're going to do a little bit of work on that front.
42
00:02:59,170 --> 00:03:02,290
But let's see if we can press it and see that print statement appear.
43
00:03:02,830 --> 00:03:06,790
So if I click on the button, sure enough, we see how they're inside of our terminal.
44
00:03:07,360 --> 00:03:08,980
OK, well, that definitely works out.
45
00:03:09,460 --> 00:03:10,950
So let's take a quick pause right here.
46
00:03:10,960 --> 00:03:15,010
We'll come back the next section and we're going to figure out how we can get that little plus icon
47
00:03:15,010 --> 00:03:16,810
to display inside the button as well.
48
00:03:17,190 --> 00:03:19,230
It's a quick break and we'll see you in just a minute.
4908
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.