Avatar ·

How to set text in EditText in Kotlin? Problem with findViewById and setter

Hello everyone! I just started learning Kotlin for Android and encountered a problem when trying to set text in EditText programmatically. I have a simple screen with an input field, and I want to set some default text in EditText when a button is pressed. Here is my code: ```kotlin class MainActivity : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_main) val editText = findViewById(R.id.myEditText) editText.text = "Hello, world!" // Error! } } ``` But on the line `editText.text = "Hello, world!"` the compiler gives an error: "Type mismatch: inferred type is String but Editable was expected". I also tried writing `editText.setText(