-1

I am attempting to perform a simple mathematical operation on one editText field which changes the value of another editText field (a unit conversion calculator).

 inchesEditText.setText(String) = (metersVal.toString().toDouble() * metersToInchesVal).toString()

The following error was returned when setting the text of the editText field:

Error:(24, 28) None of the following functions can be called with the arguments supplied: public final fun setText(p0: CharSequence!): Unit defined in android.widget.EditText public final fun setText(p0: Int): Unit defined in android.widget.EditText

Any help would be much appreciated. Thanks

Cam H
  • 1
  • 1
  • Instead of `inchesEditText.setText(String) = ` use `inchesEditText.text = ` or just pass the value on the right hand side to the setText() function – EraftYps Jun 18 '20 at 04:14

2 Answers2

0

you need to do something like below. If you want to set value in EditText then you have to set value inside yourEditText.setText('yourvalue') and yourvalue must be in String format. check below,

inchesEditText.setText( (metersVal.toString().toDouble() * metersToInchesVal).toString() )
Mehul Kabaria
  • 6,404
  • 4
  • 25
  • 50
0

In kotlin you can write in below way :

mBinding.txtHandlerTimer.text = (metersVal.toString().toDouble() * metersToInchesVal).toString()

Thanks

webaddicted
  • 1,071
  • 10
  • 23