Welcome back.
And this video, we are going to add this little icon here at the top and also this forum here in which
we then can enter an email address of a member that we want to add to our list.
And, yeah, that's pretty much it.
So let's get started with that.
Of course, the code that then triggers the whole event, that's what we're going to do in the next
video.
But let's start with what you have seen there.
So the first thing that I'm going to create is a new menu.
So let me go over to my resources menu.
And here let's create a new menu resource file, which I'm going to call menu at member.
And here I want to add an item as usual, and that item will have an I.D..
Which will be action at member.
Then we need to use an icon and here I'm going to use a plus icon, so I see me look, if I can find
that, I think I don't have one.
I think it makes sense to just create one.
I see this plus I can.
I see Victor add twenty four DP, so I'm going to call it.
All right, I see Victor at 20, 40 deep, then the order and category as we only have one, we're going
to use one hundred and title should be.
And here I think it makes sense to use.
Yeah, using new strength and by the way, we're going to use some more strings and also some more dimensions
so you can just download the updated String and dimensions file.
Here we are using at number then to cancel ad and search member texts.
OK, so all of those strings need to be added as well as if we go to our dimensions, we will need some
more dimensions here because we're using dialogs and everything.
So just download the latest version of this file and then you don't have to type all of that here.
OK, so it's just the dimensions.
We don't want to go through that in too much depth.
OK, then we can finish off the member.
So here we can now go ahead and use it.
So here.
And remember the string here?
And then.
I'm going to say show as action always, so this one should always be visible as an action that can
directly trigger.
OK, so let's add up here as well.
Let's add the namespace create namespace entry.
All right.
So that is it for this menu.
And next, we're going to add this.
Dialogue here, so you can try to build yourself or you can just copy one from the code that we used
in one of the earlier projects.
OK, so now I'm just going to add that file into our project.
You can also download it.
So either you try to build it yourself or you download it.
I think trying it yourself would be a great exercise so that you can just try to add this functionality.
All right.
So let's go and look at this file.
Which I'm going to call.
Dialogue search member, or which is called like that, so let's look at it so we have a frame layout
and then we have a cart view inside of that frame layout.
So it's this cart, you hear, and then we have a text, you an email and two more text use.
It's not buttons, right?
So we have this linear layout in which we then have a text you on.
Then if we have a separator again or a divider, which is this view here.
Then we have an input layout within that, we have an edited text, which is this email here that we
can enter.
Of course you could rename it to add member because we're not really searching.
Right.
So we have this text to you which says search member.
So I'm just going to rename that ED member.
All right, text at member.
Then we have a linear layout which positions the two buttons next to each other, which are not really
buttons, but it's text use.
OK, so we're using those two text use as buttons.
So we have a weight of one so that they have the same with.
That's the idea here, even though we set the with a zero density pixels, but by applying weight to
it, they will be equally wide.
All right.
Then we have some padding.
We have a text that we assign to them the specific text size color, which is our color accent, and
then we have the secondary text color for the other buttons.
So we have to add and cancel button having slightly different text colors here.
OK, but up to this point, this was nothing new, so I'd say let's implement those.
Elements that were just prepared, so first of all, let's implement the menu in our members activity.
So here, as it seems, we don't have a function that it takes care of that.
So whenever you use a menu, you need to add two functions.
So it's the uncreate options menu.
Uncreate options menu.
And then you need them on options, items selected.
So if you want anything to happen, if one of those items is clipped and usually you should want that
like so on options item selected.
So first of all, in the uncreate options menu here, we want to inflate the menu, OK, so we used
the menu inflator and then we inflate our our menu, that menu at member, and then we need to pass
the menu from the on options, create or create options menu function.
Now here the menu inflator should be with a capital I.
And then we can go ahead and at the UNCLICK event, so let's just do that in here so we can just say
one item, that item I.D. is equal to our dot eyed dot.
And here we called this one action at member.
If that one is clicked, then I want to display the dialogue.
OK, so if you want to display the dialogue, you, of course, need to prepare the dialogue.
So I'd say, let's just do that real quick so we will need to create a new function for this.
And I'm going to call this one.
Private fund.
Dialogue search member.
Which them, first of all, creates a dialogue, so we have the dialogue object by dialogue with the
context that we need to pass it.
So it's always the same approach, right, then we can give it a constant view so that it has a specific
appearance.
So dialogue sets content view here.
We say that it should be our art or lay out dialogue search member, which is this XML file that we
created.
So we say, OK, this is how you should look.
Then we add an on click listener for the two buttons.
So one of them is TV ad.
Said on Lisner.
And the other one is dialogue.
But TV cancel and that's the easy one.
So another set and click listener, and here we just dismiss the dialogue.
OK, and of course, we also need to make sure that the dialogue is shown at one point of dialogue that
show.
OK, so now once we click on the button, we want to call this dialogue search member.
OK, so we want to call dysfunction here.
And when we click on the plus button, but then, of course, what do we want to do when we click on
the add button?
Well, here we want to first of all, check if the email or get the email user entered email is going
to be dialogue that etty email search member to text to straight.
Or actually, it's not to text, but it's just a text.
OK, so text to string.
And now we can check is it empty because if the user didn't enter anything, we don't want to do anything.
So email is not empty if it's not empty.
Then.
For now, we will just dismiss the dialogue.
Of course, we will need to implement the logic here.
OK, so here to do implement adding member logic.
And then if it's empty, then we just want to let the user know that he should enter an email address
here.
OK, so I'm just going to do it with the toes here, saying, make text, please enter your email address.
Now, there is one less thing to do, and that is to return true in this case, because then all is
good and we can return true because it expects a billion, which is going to say, all right, all is
fine.
We're done with doing the action when you display this menu.
OK, I think at this point we should be able to test it on our application.
So let's do that.
And we are still missing this dialogue round it.
So the shape here and we can create this drawable resource.
So let's just do that and it will be a shape.
So let's create a new shape here.
OK, so here I want to, first of all, define it as a rectangle.
So if we look at it.
We can see that this here is a rectangle that we're using, so.
That's used to shape.
Rectangle, then I have a solid background, so a solid color, which is just going to be white.
And here, of course, I have to add the hashtag.
And then I have corners here which are around it, so I just give it a radius of 10 density pixels.
All right, and that's it.
So this is our sheep.
I look around XML now let's go ahead and test it.
All right, so that we are approaching Menasche now, let's go over to our board with image.
Here, let's go to members.
Now, let's click the button, you can see the screen opens its console directly is closed.
Click this, you can see please enter members email address.
So I'm just going to say test at test dot com.
But of course, nothing will happen for now when we click this, because just dismisses that dialogue.
OK, so that is it for now and say let's implement the functionality behind the add button in the next
video.
So see you there.