I wanted to display text in EditText when I clicked on this. But using it does not allow this.
`class MainActivity : AppCompatActivity() {
private val MY_LOG = "myLog"
lateinit var binding: ActivityMainBinding
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
binding = ActivityMainBinding.inflate(layoutInflater)
.also {
setContentView(it.root)
}
binding.etTest.setOnClickListener {
binding.etTest.setText("$it")
it.setText("String")
}
}
}`
Why if "it" is EditText not working setText()?

Basically OnClickListener is interface which has onClick method which will give you View class and View class doesn't have any method for setText. Due to that you are not able to call setText method.