‫Instructor: Hi!
‫Within this lecture we are going to finish
‫our user interface
‫by solving some problems that we may face
‫when we run it on emulator.
‫As you can see, we didn't click
‫on this button infer constraints like we did before.
‫So we don't have constraints
‫and the outcome of that might be very confusing.
‫So let's run this in this state and see what happens.
‫So when we don't add constraints to our layout
‫actually Android doesn't know where to locate those views.
‫So all of the views will be in a different state than this.
‫They will be all collected
‫on the left upper side of our emulator
‫once it builds,
‫once it's installed on our emulator.
‫As you can see now
‫we see everything on the left upper side corner.
‫So this is not good and this is because of the constraints.
‫So in order to add constraints,
‫we can't just click on this button, don't do that.
‫I'm just gonna do that for example.
‫And as you can see, it kind of distorted,
‫especially this buttons.
‫So if you do command Z or control Z,
‫it will go back to its own previous state
‫and how can we overcome that problem?
‫So we can actually add constraints manually,
‫one by one
‫but it will take a lot of time right now
‫and we wouldn't even get very good result out of that.
‫But rather than that, I'm just gonna go for layout section
‫over here, layouts tab.
‫So I'm going to look for linear layout.
‫You can actually search it from here as well.
‫So this is linear or linear layout, and there are two kinds.
‫One is horizontal and one is vertical.
‫So as you can see, the vertical is not
‫what we are looking for at this point,
‫but we are looking for horizontal
‫because we want to align those buttons horizontally
‫inside of a stack.
‫So this is what linear layout exactly does.
‫So we are going to bring in the linear layout
‫into our layout.
‫Okay? Just bring it in.
‫And as you can see,
‫you cannot actually see the linear layout.
‫It's not a view like an imagery or a button.
‫You can just drop it anywhere you want
‫because then we will be able to move it on.
‫Right now after you drop it
‫you can see it somehow
‫but the buttons are not inside of the linear layout.
‫So you can either drag and drop in the buttons like this
‫or you can do that within inside
‫of the Competent Tree on the left hand side.
‫So for example,
‫if I want to add button two, underline your layout
‫I'm just going to drag it in like this, like this.
‫And for the last one, like this.
‫So right now, I have my linear layout over here,
‫and all the buttons are stacked inside
‫of my horizontal layout.
‫Now I get to do this, okay?
‫Now I have my button side by side,
‫and if you try to move it, and by accident,
‫I believe I moved one of the buttons.
‫So let me do command Z.
‫And then I'm just trying to move all the linear layout
‫but I cannot manage it.
‫I believe we can do that by choosing this
‫and dragging it from the blueprint like this.
‫Here we go.
‫Now it works.
‫So if you cannot see the blueprint
‫you can come up over here to this blue button
‫and just choose design and blueprint.
‫So here you go.
‫Now I have exact look that I'm looking for.
‫So I have buttons side by side.
‫They're actually looking great.
‫They're right next to each other and they're in order.
‫So now they're inside of a horizontal layout.
‫Now I can click on this infer button
‫infer constraints button, and it will be inferred like this.
‫As you can see, now, it's not distorted.
‫So do your adjustments
‫move any view to the location that you want
‫and then try to hit infer constraints on your own.
‫And when you are done
‫just run it on the emulator from scratch.
‫And once we do that, we will see, here we go.
‫It's now looking fine.
‫Now I have this edit text over here,
‫I have the buttons and I have the result text as well.
‫So we are almost done.
‫So we have all these IDs in text views and edit texts
‫but we don't have on click methods inside of every buttons.
‫So remember what an on click button, on click method does.
‫It connects your method on the Java file with your button.
‫So whatever you write here,
‫if you write the exact same thing on your Java file,
‫then it will be your assigned method.
‫So you can do whatever you want with this button.
‫So I'm gonna call this sum, okay?
‫And I'm gonna call this like deduct
‫and then multiply
‫for the third one
‫and then the white for the last one.
‫So here you go.
‫As you can see, we are getting some errors
‫on the left hand side as we have placed
‫all the on click methods here,
‫but not in the Java section.
‫So that's what we are going to do within the next lecture.
‫We are gonna start with defining all those views
‫into our Java code,
‫and then we are gonna move on to
‫the actual mathematical operations
‫and we're gonna end this application later on.
‫So, see you in the next lecture.