android studio unresolved reference Intent and Button

SoulsReaper

New member
Dec 3, 2023
2
2
3
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
 
Welcome to Android Central! I moved this from the Nougat forum to the Software Development forum for more specific traffic.
 

Forum statistics

Threads
954,587
Messages
6,962,089
Members
3,163,079
Latest member
marcociot