google-developer-training / basic-android-kotlin-compose-training-tip-calculator

Apache License 2.0
61 stars 93 forks source link

Intro to state in Compose: Android Basics with Compose #177

Open maya-ivanova opened 7 months ago

maya-ivanova commented 7 months ago

URL of codelab https://developer.android.com/codelabs/basic-android-kotlin-compose-using-state?continue=https%3A%2F%2Fdeveloper.android.com%2Fcourses%2Fpathways%2Fandroid-basics-compose-unit-2-pathway-3%3Fauthuser%3D1%23codelab-https%3A%2F%2Fdeveloper.android.com%2Fcodelabs%2Fbasic-android-kotlin-compose-using-state&authuser=1#9

In which task and step of the codelab can this issue be found? Intro to State in Compose, step 10

Describe the problem on line 90: EditNumberField( value = amountInput, onValueChanged = { amountInput = it }, // this is the correct naming modifier = Modifier.padding(bottom = 32.dp).fillMaxWidth() ) while this is what is found in the codelab: EditNumberField( value = amountInput, onValueChange = { amountInput = it }, //incorrect modifier = Modifier .padding(bottom = 32.dp) .fillMaxWidth() ) and then again, on line 109: TextField( value = value, singleLine = true, modifier = modifier, onValueChange = onValueChanged, //this is the correct naming label = { Text(stringResource(R.string.bill_amount)) }, keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Number) ) while this is what is found in the codelab: TextField( value = value, onValueChange = onValueChange, //incorrect singleLine = true, label = { Text(stringResource(R.string.bill_amount)) }, keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Number), modifier = modifier )

That's not a big deal, but i so much enjoy your tutorials and i advance so fast, that i wanted everything be perfect as it should. when i launched the code with the incorrect namings, i got errors, the sources of which i could only spot out after a comparison with the solution code you have provided (so i guess everyone else may do it too). As a novice i could not possibly know the difference between onValueChange and onValueChanged, so i just follow the instructions and they seem misleading in this case. Thanks for everything and hugs! onValueChanged