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.
 

Latest posts

Trending Posts

Members online

Forum statistics

Threads
956,246
Messages
6,967,206
Members
3,163,494
Latest member
Jimana