Let's go ahead and make our job even better and make it more dynamic.
Let's go back to our code actively mean example there.
What are we going to do?
We're going to add another Ouija type here.
So we have the button widget and the text of your widget.
The next one we are going to add, it's going to be a text type, but it's going to be what we call
a plain text.
So if you click, go back to our palette, make sure the text is selected, go to plain text.
So if you drag it and put it right there.
There we go, you can see here now we have a an added tax to what we call an edit text.
What is an added text letter?
Text allows us to, as a name, imply to add a text so users can actually end or something.
And of course, we need to add a few constraints.
So I'm going to do the same thing.
But they're left constrained, right constraint, and I want this to always be at the top of our button
as such.
Let's go ahead and give a quick run, full run that way, because we've added a few things.
And see what's going to happen.
And there we go, so we have this added text there.
In fact, whenever you click that notice, now it's ready for us to add something to it.
Very good.
So it looks it's looking real good if we say your name.
It still says hello, Georgina, because that that was the last code we wrote.
So nothing is changing yet.
But at least we know that are at a Texas showing clicked on our text to our right.
We still have our attributes here.
Again, if you don't see it could be hidden like that.
All you need to do is just click on this tab here.
There we go.
And should see our attributes tab.
All right.
So what is it we want to change?
Well, first of all, its changes adds touch such a long ID.
I mean, just kind of all this added text name like this.
OK, hit enter.
This will happen.
This just says that we want to refactor, making sure that we are indeed changing this name everywhere
else that is need that needs to be changed.
That's fine.
Say factor and that's good.
Now we've changed the idea of our added text to something more manageable.
And next thing we're going to do is I'm going to change the name.
I don't want it to say name like this.
I'm going to change that to have empty as such.
Now it's empty.
And what I can do also, I can guide our users so that they know what needs to be.
And what are we going to add is what we call a hint.
OK, so call this input.
So if you go back to our attributes, scroll down.
There is a hint.
So I'm going to go ahead and say here, enter, name hit, enter.
And now you can see the enter name is actually grayed out.
This is how it's going to look like, right when we were on the application.
In fact, let's go ahead and run this real quick.
OK, there we go.
Now it says and her name, if you click now, it's all empty.
So he tells us, gives us this visual signal, what needs to be entered.
So in this case here, I can answer whatever I want and of course, say, OK, and hit enter and something
happens, which nothing has happened so far.
OK, so we're going to do the same thing now.
We have to connect this to our Java, going to do the same thing we did with other widgets.
So in this case, when, say, private, it's going to be edit text.
There we go and we say enter name.
So now we're going to do the same thing, use find view by ID to grab it from our user interface.
So I'm going to enter a name.
This is where I'm actually creating the widget find by ID or that ID dot and I'm going to say any text
that's dated, what is that we wanted to happen at this point is that whatever user entered, you know,
edit text and then users say show name, we're going to pull whatever it's entered to show inside of
our TextView.
So how do we get then or retrieve what's entered in this case?
In our edit text?
Very simple.
We know whatever is being entered in this case is going to be a text, right.
Is some sort of a text.
So what I'm going to do is inside of our own click here because all of this is going to happen, sort
of don't want to click.
So when users click, I'm going to create a variable called string, OK?
And call this name so equal.
And then I'm going to use the enter name and say invoke.
If you invoke a method call, get text what it does to get text.
It gets the text from our enter name, which is indeed an edit text, very handy.
And then I'm going to say to string just to make sure that whatever is entered, just to convert everything
to make it a string.
OK, so now we have this variable which will contain whatever is inside or whatever was added inside
of our enter name at a text.
OK, so what do I do next?
Well, very simply, I can delete what is inside there and then I'm going to spend or concatenate by
putting a plus sign outside of our double quotes there and pass the variable name.
So this will make our app even better because now we don't need to depend on coming down here and type
ourselves or hard code the text.
Instead, we are going to get the text dynamically from our edit text, which is fun.
So in this case here, let's go ahead and do a full run and see this working hopefully.
Oh, let's see.
Let's say, Paulo, I can just click there and say run.
Look.
Hello Paolo.
If I say a lead you.
And say, look at that.
So now it's very, very dynamic, even say some gibberish as such.
And there it is.
OK, very good.
Now, look what's going to happen if I don't add anything and say show name, this happens not very
flattering.
It's not a big problem, but it just doesn't look great.
How do we make it so that if there is nothing inside here, we can add some sort of a generic name?
It's very simple.
We can put inside of an if statement so we can say something like this.
If look at this, if name is empty, we do nothing for now or else we want to make sure that then I'm
going to cut all of this and put all of there.
So if name is empty, meaning the string here, it doesn't have anything.
What is that we want to do?
We're going to say name text and we're going to say said hello, bond, something like this, or else
we're just going to get whatever the name has.
It makes sense.
So we make sure that the users don't end up with something like this, these cases where there's nothing
entered and then it shows just, hello, ankomah.
That's just not flattering.
OK, OK, let's go ahead and keep a run real quick here.
OK, moment of truth.
So it's empty.
I haven't heard anything.
Click Hello Bond.
Very nice.
However, if I say Ruthe.
And there you go, it works, so you've built your first Android app that does something fun, so you've
learned a few things here.
Now, remember, most of this may not make a lot of sense.
In fact, I assume that it actually makes no sense.
But the idea is I just want you to go through this motion of getting used to doing this and build your
first Android application again.
Again, I repeat, don't worry.
If none of this makes sense, it will make sense.
I promise.
I just want you to go through this and get this working and and be happy.
OK, now, one thing we can do before we leave is we can make this a little bit better.
So let's go to our activity, my next e-mail here.
One other thing we can do is we can change the width of this entire widgets.
So let's click our enter name here at a text and what we can do.
Let's go to our layout widget and our arrow here.
Notice we have Ropp content.
Ribe content means that the widget will only take enough space that it needs.
But what we want to do, we can also match constraint, meaning we can make it as big as the constraint
that it has.
As you can see now, it's bigger.
I can do the same with our show name and say match that and I can do the same, of course, with our
added text notice now because I moved things around before, as I move things around, that means then
we have defined width, which is 152 DP.
OK, so to make it more flexible I can also do the same.
So this is just an option.
Let's go ahead and run full run here so you can see.
OK, now it doesn't look that great, but it's just an option I wanted to let you know, OK, so I can
see here, I can see James again, my favorite name, I guess, and you can see it's still working.
So I don't want you to get too distracted, but I just want to show you different things you can do.
And remember, this is just the beginning.
I want you to get this app working.
I want you to get excited of things that are to come and how amazing building Android apps is.
And I hope you are able to see and get excited about Android development if this makes no sense and
don't worry.
In fact, like I said, I assume that this will not make any sense.
I just want you to get a little taste of building a fun little Android app, and I hope you are as excited
as I am to really get deeper into Android development.
All right.
Congratulations.
And I'll see you in the next video.