setOnClickListener is not showing in intellij even the textview names i can't write them without R.id.the_name
CodePudding user response:
This is not how android works. It seems you miss the very basics.
R.id.button is just an Int, the id of a view. To get the view you can do findViewById(id) for example.
So then in your case maybe:
val button: Button = findViewById(R.id.button)
button.setOnClickListener {
//on click
}
CodePudding user response:
You should implement view binding to your projects.
https://developer.android.com/topic/libraries/view-binding
So instead of val btn = findViewById<Button>(R.id.yourbuttonId) you can val btn = binding.yourbuttonId
