1
00:00:00,240 --> 00:00:05,130
All right, now, let's look at the custom dialogue function that we have here, so let's go all the

2
00:00:05,130 --> 00:00:07,830
way back up here where we are actually calling it.

3
00:00:07,980 --> 00:00:13,890
So here in the on create method, I have this button custom dialogue which calls the custom dialogue

4
00:00:13,890 --> 00:00:14,370
function.

5
00:00:15,030 --> 00:00:15,390
All right.

6
00:00:15,750 --> 00:00:17,820
Now what is a custom dialogue?

7
00:00:17,850 --> 00:00:20,460
Well, it's this dialogue that I have here.

8
00:00:21,300 --> 00:00:22,290
Why is it custom?

9
00:00:22,530 --> 00:00:26,310
Well, that's because I created this dialogue myself.

10
00:00:26,310 --> 00:00:29,370
So the whole UI of it, how it's looking.

11
00:00:29,370 --> 00:00:35,340
So the text here, the text there, the buttons and so forth, so I can create my very own dialogue

12
00:00:35,340 --> 00:00:36,000
as I want.

13
00:00:36,390 --> 00:00:39,030
It can look as crazy as I want and as good as I want.

14
00:00:39,510 --> 00:00:44,850
And then I am creating a dialogue again and I'm getting this one custom dialogue.

15
00:00:45,270 --> 00:00:50,940
And then I set the content view and you probably know that content view already.

16
00:00:51,480 --> 00:00:53,250
We've used it in our.

17
00:00:54,350 --> 00:01:00,170
On create every single time when we start to lay out to beat the activity, men so on create we have

18
00:01:00,170 --> 00:01:04,879
said content view, which just sets the activity men, which is our XML file.

19
00:01:05,510 --> 00:01:06,260
This one here.

20
00:01:07,550 --> 00:01:14,700
This design as the UI for our main activity now, we do the same thing for our custom dialogue.

21
00:01:15,080 --> 00:01:17,540
We say OK for the custom dialogue.

22
00:01:17,540 --> 00:01:20,030
I want to set the content for you to be this dialogue custom.

23
00:01:20,540 --> 00:01:24,920
Now this dialogue custom is, as I said, something that I created myself, which I have here.

24
00:01:25,280 --> 00:01:29,110
So it's this UI or this XML file that I have here.

25
00:01:29,240 --> 00:01:33,380
So I have a texture, which is the custom dialogue, which is this text here.

26
00:01:33,560 --> 00:01:34,400
This text view.

27
00:01:36,410 --> 00:01:41,390
The very first one, and let me drag it up a little bit here, so it's a little more visible.

28
00:01:41,870 --> 00:01:47,870
OK, so I have this texture, which rips the content and has a text here custom dialogue title.

29
00:01:48,140 --> 00:01:51,200
I said the color to black and I said the state's exercise here.

30
00:01:51,770 --> 00:01:54,380
Then I have another texture, which is this gray text.

31
00:01:54,590 --> 00:01:58,950
So what I do is I have a slightly less big text.

32
00:01:58,970 --> 00:02:06,710
So 14 and I have text color here and two such dark gray and a little text, a little margin to have

33
00:02:06,710 --> 00:02:08,210
some space in between those two.

34
00:02:08,449 --> 00:02:09,320
And that's pretty much it.

35
00:02:09,830 --> 00:02:15,170
And then I have a linear layout because I want to put those two buttons, so to speak, next to each

36
00:02:15,170 --> 00:02:15,470
other.

37
00:02:15,860 --> 00:02:19,600
So they look like buttons and they act like buttons, but they are actually text views.

38
00:02:19,610 --> 00:02:21,170
At least that's how we did it here.

39
00:02:21,530 --> 00:02:23,720
But you can, of course, use buttons here as well.

40
00:02:24,290 --> 00:02:29,960
But here the text is they have a property called foreground.

41
00:02:30,380 --> 00:02:37,190
So what you can do is you can set this program to be selectable item background so it will create these

42
00:02:37,850 --> 00:02:39,500
gray borders here.

43
00:02:39,590 --> 00:02:41,780
Let me make it a little bigger so you can see it better.

44
00:02:42,110 --> 00:02:47,990
So once you hover over to concede has those gray borders, so it appears like a selectable or clickable

45
00:02:47,990 --> 00:02:48,350
button.

46
00:02:49,490 --> 00:02:53,630
Or at least a selectable item and then text color is said to read.

47
00:02:53,930 --> 00:02:58,070
Gravity is set to center and the layout white is sent to one.

48
00:02:58,160 --> 00:03:04,100
So this means that I want the two buttons to be the same because I set the layout white to one for both

49
00:03:04,100 --> 00:03:06,660
of them, because they're both in a linear layout.

50
00:03:06,680 --> 00:03:13,340
They are entered horizontally, so next to each other and they have the same with at least that's what

51
00:03:13,340 --> 00:03:19,010
I'm defining with a layered white because I set a layered with to be zero density pixels, so they usually

52
00:03:19,010 --> 00:03:21,110
would have no density pixels at all.

53
00:03:21,560 --> 00:03:28,160
But because I'm setting the layout way to one now, they just take the space that is available within

54
00:03:28,550 --> 00:03:32,030
their container, which is this linear layout.

55
00:03:32,600 --> 00:03:36,200
OK, so the linear layout takes the whole with each parent.

56
00:03:36,470 --> 00:03:42,620
Of course, we have some padding around here, which is defined in our linear layout at the highest

57
00:03:42,620 --> 00:03:45,950
level, so it's just padding here to stand at city pixels.

58
00:03:46,220 --> 00:03:48,530
But overall, we have the full overview here.

59
00:03:49,340 --> 00:03:50,180
All right, so then.

60
00:03:51,580 --> 00:03:56,590
Let's look at the text, it's submit very basic, and then we have the same thing for the cancel button.

61
00:03:56,770 --> 00:03:57,190
OK?

62
00:03:57,580 --> 00:04:03,160
Very same functionality only difference is that the Texas different and the color is different.

63
00:04:04,270 --> 00:04:04,690
All right.

64
00:04:04,840 --> 00:04:10,510
And of course, the ID. I mean, we need to have an I.D. in order to know which of the text views was

65
00:04:10,510 --> 00:04:12,130
clicked or was touched.

66
00:04:12,940 --> 00:04:14,080
All right, coming back to the code.

67
00:04:15,010 --> 00:04:18,440
Now we know how to set the dialogue right now.

68
00:04:18,459 --> 00:04:21,519
Custom dialogue TVs submit set on Click Listener.

69
00:04:21,550 --> 00:04:25,540
So in a custom dialogue, we have a text you call submit.

70
00:04:25,900 --> 00:04:26,560
Let's look at it.

71
00:04:27,190 --> 00:04:28,960
That's this text you hear.

72
00:04:29,410 --> 00:04:31,000
So what should happen once we click on it?

73
00:04:31,030 --> 00:04:38,020
Well, that's what we defined in the set and click listener, as we have done before and the main activities

74
00:04:38,290 --> 00:04:39,490
on create function.

75
00:04:40,090 --> 00:04:41,950
OK, so here I'm just using a toast.

76
00:04:43,020 --> 00:04:49,320
Do write some text, click submit, and I am dismissing the custom dialogue so that it disappears once

77
00:04:49,320 --> 00:04:53,970
a user clicks on something and then the same thing goes for our TV cancel.

78
00:04:53,970 --> 00:04:55,710
So we also have a certain click listener.

79
00:04:55,950 --> 00:05:00,330
So one thing you might wonder is why are we using application context and not this year?

80
00:05:00,780 --> 00:05:04,470
Well, as it seems, this also works so you can also use this year.

81
00:05:04,800 --> 00:05:12,140
But sometimes application context is required because you are within a closure and then it's, yeah,

82
00:05:12,370 --> 00:05:17,460
safer to use the application context, which will be the context of this activity, our main activity.

83
00:05:18,010 --> 00:05:23,340
OK, but understanding closures and what I just said is not something that you need to do at this point

84
00:05:23,340 --> 00:05:25,110
of the course, so no worries about that.

85
00:05:25,530 --> 00:05:28,140
So just use this for applications context.

86
00:05:28,140 --> 00:05:32,190
If this doesn't work, then use application context in this situation.

87
00:05:32,340 --> 00:05:32,640
All right.

88
00:05:33,060 --> 00:05:36,660
So and then of course, you need to show this custom dialogue at one point.

89
00:05:37,140 --> 00:05:37,430
All right.

90
00:05:37,440 --> 00:05:39,420
And that's how we can create this custom dialogue.

91
00:05:40,750 --> 00:05:41,800
Submit and cancel.

92
00:05:42,580 --> 00:05:48,100
All right, so I'd say we're going to look at a custom progress dialogue in the next video, so I'll

93
00:05:48,100 --> 00:05:48,550
see you there.

