How to start new activity on button click

后端 未结 24 1675
傲寒
傲寒 2020-11-21 05:54

In an Android application, how do you start a new activity (GUI) when a button in another activity is clicked, and how do you pass data between these two activities?

24条回答
  •  野性不改
    2020-11-21 06:47

    Although proper answers have been already provided but I am here for searching the answer in language Kotlin. This Question is not about language specific so I am adding the code to accomplish this task in Kotlin language.

    Here is how you do this in Kotlin for andorid

    testActivityBtn1.setOnClickListener{
          val intent = Intent(applicationContext,MainActivity::class.java)
          startActivity(intent)
    
     }
    

提交回复
热议问题