Hello,
sorry my english,
this problem I only have on Android Studio, if I use only Kotlin with readLine or using numbers intead of editText (textField on Jetpack Compose) work’s here.
I trying to catch 2 fields of editText and multiply then, but, I try 4 diferent ways and not work.
This is my last try, just learn to use the “data class”, but, the same, open the emulator, put the numbers and when I press the button to “do the math”, the APP close.
I will put the kotlin LAST code I try here (on burnout mode):
data class Numeros(
var num1: String = findViewById(R.id.valor1).toString(),
var num2: String = findViewById(R.id.valor2).toString()
)
{
var resultado = findViewById<TextView>(R.id.resultado)
var calcular = findViewById<Button>(R.id.calcular)
fun multi() = num1.toFloat() * num2.toFloat()
}
val res = Numeros()
res.calcular.setOnClickListener {
res.resultado.text = res.multi().toString()
}
How do I do here?