How to implement setText to integer dataType in Kotlin?

126 Views Asked by At

I want to set data from my editText which has integer typedata. if it is string, we can make setTake, but how we can implement it at integer?

The warning is

None of the following functions can be called with the arguments supplied. setText(CharSequence!) defined in com.google.android.material.textfield.TextInputEditText setText(Int) defined in com.google.android.material.textfield.TextInputEditText

1

There are 1 best solutions below

0
Ivo On

Your code shows data is of type UserDto. I don't know what that class looks like but it has a field called phoneNumber. This is what you are passing to setText(). I can't tell what type this phoneNumber is because you haven't shown us your UserDto class but the error tells us that it's neither an Int nor CharSequence, which it needs to be. You can try to do this maybe to make it work

binding.etPhone.setText(data.phoneNumber.toString())