I'm really sorry if this question is at all redundant. I have read several posts and for some reason this issue does not seem to come up for anyone else. As such, I really hope it's solvable.
Long story short, I am a beginner in Android dev and I'm working with Kotlin. When I go to add "onClickListener" to a button, I get an error. The id is set to "button" so presumably I can just write "button.onClickListener {}" and begin my code. But for some reason this gives me and error.
As you can see here, I am not getting any methods provided for me off of "button"
The error I am getting is "kotlinx.android.main.activity_main.button?" (I'm not sure if that helps or not).
Thank you all so much for helping to get me started with Android.
EDIT
Based on feedback (THANK YOU SO MUCH BY THE WAY!!!) I clicked "ALT" and "Enter" and told the code to "import"
It brought in the line: "import kotlinx.android.synthetic.main.activity_main.*"
Unfortunately, I still do not get the "onClickListener" option though from intellisense. I believe I have this declared as a button in the "activity_main.xml" file but maybe not? Here are my screenshots:




That is because the IDE does not recognize the
buttonsymbol. You have neither declared it nor imported it.That tooltip message not an error. The red highlight of
buttonis an error. The underline means "hey, we are not sure what you mean by this symbol, but we have some imports that match!". The tooltip is indicating that if you press Alt-Enter (Windows/Linux), that it will add animportstatement forkotlinx.android.main.activity_main.buttonto your list ofimportstatements at the top of the Kotlin file. Ifbuttonis a widget in youractivity_mainlayout resource, then this will work and will give you the ability to set a click listener on it.