I am starting to learn android development using Kotlin. I am trying to call object ID in my MainActivity.kt but I am getting an error Unresolved reference : btnDatePicker
Given below is the code
<Button
android:id="@+id/btnDatePicker"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="15dp"
android:background="#0E0B0B"
android:text="SELECT DATE"
android:textColor="#C5BBBB"
android:textSize="20sp"
android:textStyle="bold"
app:backgroundTint="#186C64" />
Given below is the code in MainActivity.kt
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
btnDatePicker.setOnClickListener { Toast.makeText(this, "works", Toast.LENGTH_LONG).show() }
}
}
On hovering over btnDatePicker I see the below options but not sure how to proceed