0
Hello, I’m doing an android Studio project with Kotlin and I’m having the following error.
equal.setOnClickListener {
try{
val expressao = ExpressionBuilder(expressao.text.toString()).build()
val resultado = expressao.evaluate()
val LongResult = resultado.toLong()
if ( resultado == LongResult.toDouble()) {
result.text = LongResult.toString()
}else{
result.text = resultado.toString()
}
}catch (e: Exception) {
}
}
Specifically in this part (expression.text.toString()). build() I’m having trouble adding expression in expression.text.toString.
If anyone can help me, I’d appreciate it.
I forgot to mention that is giving error in the compilation Unresolved Reference: expression
– Samuel Balena
In the same line where you declare the variable
expressao
, you try to use it, that’s the problem, soUnresolved reference
.– Rafael Tavares
How would I solve such a problem then ? you can show me with codes ?
– Samuel Balena
No one can solve this problem for you, there is no context to know what you try to do. Also, I have never used
ExpressionBuilder
. What I can tell you is that you need to figure out where to get this initial value for theExpressionBuilder
, because clearly it should not be of a variable that has not yet been declared.– Rafael Tavares
The worst q I saw a guy doing exactly the same code on youtube, in it everything works out, but in my project gives this error.
– Samuel Balena
And only gave this error when I tried to emulate the app in android studio.
– Samuel Balena