All right, now, let's look at the custom dialogue function that we have here, so let's go all the
way back up here where we are actually calling it.
So here in the on create method, I have this button custom dialogue which calls the custom dialogue
function.
All right.
Now what is a custom dialogue?
Well, it's this dialogue that I have here.
Why is it custom?
Well, that's because I created this dialogue myself.
So the whole UI of it, how it's looking.
So the text here, the text there, the buttons and so forth, so I can create my very own dialogue
as I want.
It can look as crazy as I want and as good as I want.
And then I am creating a dialogue again and I'm getting this one custom dialogue.
And then I set the content view and you probably know that content view already.
We've used it in our.
On create every single time when we start to lay out to beat the activity, men so on create we have
said content view, which just sets the activity men, which is our XML file.
This one here.
This design as the UI for our main activity now, we do the same thing for our custom dialogue.
We say OK for the custom dialogue.
I want to set the content for you to be this dialogue custom.
Now this dialogue custom is, as I said, something that I created myself, which I have here.
So it's this UI or this XML file that I have here.
So I have a texture, which is the custom dialogue, which is this text here.
This text view.
The very first one, and let me drag it up a little bit here, so it's a little more visible.
OK, so I have this texture, which rips the content and has a text here custom dialogue title.
I said the color to black and I said the state's exercise here.
Then I have another texture, which is this gray text.
So what I do is I have a slightly less big text.
So 14 and I have text color here and two such dark gray and a little text, a little margin to have
some space in between those two.
And that's pretty much it.
And then I have a linear layout because I want to put those two buttons, so to speak, next to each
other.
So they look like buttons and they act like buttons, but they are actually text views.
At least that's how we did it here.
But you can, of course, use buttons here as well.
But here the text is they have a property called foreground.
So what you can do is you can set this program to be selectable item background so it will create these
gray borders here.
Let me make it a little bigger so you can see it better.
So once you hover over to concede has those gray borders, so it appears like a selectable or clickable
button.
Or at least a selectable item and then text color is said to read.
Gravity is set to center and the layout white is sent to one.
So this means that I want the two buttons to be the same because I set the layout white to one for both
of them, because they're both in a linear layout.
They are entered horizontally, so next to each other and they have the same with at least that's what
I'm defining with a layered white because I set a layered with to be zero density pixels, so they usually
would have no density pixels at all.
But because I'm setting the layout way to one now, they just take the space that is available within
their container, which is this linear layout.
OK, so the linear layout takes the whole with each parent.
Of course, we have some padding around here, which is defined in our linear layout at the highest
level, so it's just padding here to stand at city pixels.
But overall, we have the full overview here.
All right, so then.
Let's look at the text, it's submit very basic, and then we have the same thing for the cancel button.
OK?
Very same functionality only difference is that the Texas different and the color is different.
All right.
And of course, the ID. I mean, we need to have an I.D. in order to know which of the text views was
clicked or was touched.
All right, coming back to the code.
Now we know how to set the dialogue right now.
Custom dialogue TVs submit set on Click Listener.
So in a custom dialogue, we have a text you call submit.
Let's look at it.
That's this text you hear.
So what should happen once we click on it?
Well, that's what we defined in the set and click listener, as we have done before and the main activities
on create function.
OK, so here I'm just using a toast.
Do write some text, click submit, and I am dismissing the custom dialogue so that it disappears once
a user clicks on something and then the same thing goes for our TV cancel.
So we also have a certain click listener.
So one thing you might wonder is why are we using application context and not this year?
Well, as it seems, this also works so you can also use this year.
But sometimes application context is required because you are within a closure and then it's, yeah,
safer to use the application context, which will be the context of this activity, our main activity.
OK, but understanding closures and what I just said is not something that you need to do at this point
of the course, so no worries about that.
So just use this for applications context.
If this doesn't work, then use application context in this situation.
All right.
So and then of course, you need to show this custom dialogue at one point.
All right.
And that's how we can create this custom dialogue.
Submit and cancel.
All right, so I'd say we're going to look at a custom progress dialogue in the next video, so I'll
see you there.