From the course: Android Compose with Kotlin

Unlock this course with a free trial

Join today to access over 24,300 courses taught by industry experts.

Solution: What state are you in?

Solution: What state are you in? - Kotlin Tutorial

From the course: Android Compose with Kotlin

Solution: What state are you in?

(upbeat music) - [Instructor] Let's dive into my solution for the What State Are You In challenge. We'll start with the EnterGuess composable. You already provided a checkGuess Lambda function, but you needed one more, and that's for tracking whenever the guess has changed. You would use it here in your TextField. So first we take in the guess as a parameter, and then we use the onValueChange parameter of the text field to call the guessChanged function and pass in the value. Then the final update here was in the Button onClick method to pass it checkGuess, and that's all you needed to do here for the EnterGuess composable. Now, if we move up to our main composable, that means that we needed to add a new function. So let me show you what that looked like before. When we were making a call to EnterGuess, we had the modifier, our guesss, and we only had checkGuess. But now we added this new one, whenever the guess changes. So we would update the variable in order to keep track of it…

Contents