android studio unresolved reference Intent and Button

SoulsReaper

New member
Dec 3, 2023
2
2
3
Visit site
package com.example.systemmainframe104

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle

class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)

val btnSecondActivity = findViewById<Button>(R.id.btnSecondActivity)
btnSecondActivity.setOnClickListener {
val intent = Intent(this, SecondActivity::class.java)
startActivity(intent)
}
}
}

and where it says Button and Intent they say unresolved reference error when in android studio
 

B. Diddy

Senior Ambassador
Moderator
Mar 9, 2012
165,618
4,759
113
Visit site
Welcome to Android Central! I moved this from the Nougat forum to the Software Development forum for more specific traffic.
 

Forum statistics

Threads
943,209
Messages
6,917,821
Members
3,158,880
Latest member
karim174