I have a numberDecimal EditText (codeInput) in my app, and I want the output to be multiplied by a double (tipPercent) as it is being typed, so I can display it to a textView (totalText). I tried this code:
costInput.addTextChangedListener(object : TextWatcher{
override fun afterTextChanged(s: Editable) {}
override fun beforeTextChanged(s: CharSequence, start: Int,
count: Int, after: Int) {
}
override fun onTextChanged(s: CharSequence, start: Int,
before: Int, count: Int) {
totalText.setText(s * tipPercent)
}
})
when I use this, however, I get this error:
Unresolved reference. None of the following candidates is applicable because of receiver type mismatch:
public inline operator fun BigDecimal.plus(other: BigDecimal): BigDecimal defined in kotlin
public inline operator fun BigInteger.plus(other: BigInteger): BigInteger defined in kotlin
what can I do to fix this? Thanks.
2
Answers
Try this:
This will take care of invalid input in costInput.