Advertisement
English transcript
In the MainActivity.java file, we modify the MainActivity decrement method.
First we create an integer quantity variable and
initialize the value to two.
Then we update the quantity variable to have a value equal to the current value
of quantity minus one.
In this case, the current value of quantity will be two, so
two minus one equals one.
So when we display quantity, it should have a value of one.
When I click on the minus button, then it updates to one on the screen.
I can add a breakpoint and run the app in debug mode.
If I click on the minus button, the breakpoint is triggered.
I can click step over, and then I immediately see the quantity variable
is down here with a value of two.
If I click step over again, then quantity has been decreased by one,
and now quantity equals one.
If I click resume, then the screen updates to one.
Awesome.
Now we have all the small pieces in place.
In the next video, we're going to finish hooking up the quantity picker so
that it works when you tap it more than once.
First we create an integer quantity variable and
initialize the value to two.
Then we update the quantity variable to have a value equal to the current value
of quantity minus one.
In this case, the current value of quantity will be two, so
two minus one equals one.
So when we display quantity, it should have a value of one.
When I click on the minus button, then it updates to one on the screen.
I can add a breakpoint and run the app in debug mode.
If I click on the minus button, the breakpoint is triggered.
I can click step over, and then I immediately see the quantity variable
is down here with a value of two.
If I click step over again, then quantity has been decreased by one,
and now quantity equals one.
If I click resume, then the screen updates to one.
Awesome.
Now we have all the small pieces in place.
In the next video, we're going to finish hooking up the quantity picker so
that it works when you tap it more than once.