setText returning error when attempting to input a string on an editText Kotlin Code Answer

Hello Developer, Hope you guys are doing great. Today at Tutorial Guruji Official website, we are sharing the answer of setText returning error when attempting to input a string on an editText Kotlin without wasting too much if your time.

The question is published on by Tutorial Guruji team.

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

Answer

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() )
We are here to answer your question about setText returning error when attempting to input a string on an editText Kotlin - If you find the proper solution, please don't forgot to share this with your team members.

Related Posts

Tutorial Guruji