How to solve an error "Type mismatch. Required: Editable Found: String" in Android Studio (Kotlin)

This  problem appears when you try to write a string instead of an Editable into an EditText element .

Wrong usage example: 

 binding.myEdit.text = "12345"

The solution is to write text using the setText method:

 binding.myEdit.setText("12345")

If you do not use View Binding, then see this example:

val txt = findViewById (R.id.my_text) as EditText
txt.text = "12345" // an error
txt.setText("12345") //correct

Comments

No comments yet, you can leave yours: