I'm writing a simple tip calculator app in android studio ( which is one of the programs in the
Any help is appreciated!!
CodePudding user response:
Try after removing
import java.text.NumberFormat
comment
fun calculateTip() {
val stringInTextField = binding.costOfService.text.toString()
val cost = stringInTextField.toDouble()
}
build & clean
uncomment the code in above method you will get correct import
CodePudding user response:
Seems like you do not have the latest kotlin support . Update the Kotlin version to the latest one from : File ->> Setting -->> Language & Frameworks -->> Kotlin ...
CodePudding user response:
Use
val cost = Double.parseDouble(stringInTextField)