Android Studio MainActivity.kt can’t reference ids in main_activity.xml

Published

I am new to Android Studio. I wrote a simple code in the main_activity.xml file, with ids. But when I try to reference the ids from my MainActivity.kt file. It shows an error Unresolved reference: btnDatePicker i.e an unresolved error.

I don’t know what wrong. Here’s a screenshot of my MainActivity.kt file. As you can see, when I try to call the id btnDatePicker, it returns an error.
enter image description here

And Here’s a screenshot of my activity_main.xml, as you’ll see I have circled the particular id I’m trying to reference.

enter image description here

Source: Android Studio Questions

Published
Categorized as android-activity, android-studio, kotlin

Answers

Leave a Reply

Still Have Questions?


Our dedicated development team is here for you!

We can help you find answers to your question for as low as 5$.

Contact Us
faq