Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Android Studio Kotlin Intent to another activity

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

    btnLogin.setOnClickLister {
        val intent = Intent(this, homemenu::class.java)
        startActivity(intent)
    }
} }

The Photo of the code

I have set the button for the Intent function. But it is still an error how can I fix this. The task I just only want the button after click it will head to another activity. appreciate for helping

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

It is because btnLogin is not defined.

You should define btnLogin (from activity_main xml)

val btnLogin = findViewById(R.id.btnLogin) as Button

Rest is good.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading