From the course: Programming for Non-Programmers: Android & Kotlin

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Display tapped numbers in the calculator

Display tapped numbers in the calculator

From the course: Programming for Non-Programmers: Android & Kotlin

Start my 1-month free trial

Display tapped numbers in the calculator

- [Male Voice] Now it's time to actually start writing the code for the calculator that we can actually test. 'Cause up to this point, all that we've done so far is prepare. And now we're ready to start writing the actual logic of the application. Scroll down to the very bottom of your code, and find didPressNumber, so that's that method right here. In my code it's on line 50. What we're going to do first is handle the code that happens when the user presses the numeric buttons. Remember, we set that up previously, and each button sends the appropriate number to didPressNumber. So when we press zero, then didPressNumber receives the number zero. The one button sends the number of one, et cetera. So, inside a didPressNumber, I'll tab in there. And what we're going to do first is take the number that was pressed, and convert it into a string. The reason we're doing that is because we need to store that number as a string inside of our label string property. We'll use label string to put…

Contents