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 uncreate 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 takes 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 going this one custom dialogue.
And then I set the content view and you probably know the content of you already.
We've used that in our.
Uncreate every single time when we set the layout to be the activity meant so uncreate, we have that
constant view which just sets the activity main, 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 text you, which is the custom dialogue, which is this text here, this text will.
The very first one and let me drag it up a little bit here so it's a little more visible.
OK, so if this takes you, which is the content and has a text here, custom dialogue title, I said
the color to black and I said the stage here, then I have another texture, which is this gray text.
So what I do is I have a slightly less vague text.
So 14 and I have text color here too.
Such dark gray and the 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 Eitam background so it will create this
gray borders here.
Let me make it a little bigger so you can see it better.
So once you hover over, you can see those great border.
So it appears like a selectable or clickable button.
Or at least a selectable item, and then text color is set to read.
Gravity is set to center and the layout is sent to one.
So this means that I want the two buttons to be the same because I set the layout weight 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 the layout weight because I set the layout with to be zero density pixels.
So they usually would have no density pixels at all.
But because I'm setting the layout up 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, distant pixels.
But overall, we have the full overview here.
All right.
So then.
Let's look at the text and 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 Edem I mean, we need to have an idea in order to know which of the text views was
clicked or was touched are coming back to the code.
Now we know how to set the dialogue right now.
Custom dialog, TV submit set on Click Listener.
So in a custom dialogue, we have a text you called Submit.
Let's look at it that this text you hear.
So what should happen once we click on it?
Well, that's what we define in the set and click listener, as we have done before.
And the main activity is on create function.
OK, so here I'm just using a toast.
To 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 council.
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
an enclosure and then it's 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 or application 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 the custom progress dialogue in the
next video, so I'll see you there.