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
164,931
3,928
113
Visit site
Welcome to Android Central! I moved this from the Nougat forum to the Software Development forum for more specific traffic.
 

Trending Posts

Forum statistics

Threads
941,368
Messages
6,908,329
Members
3,157,880
Latest member
GregoryNeimi