How to pass the values from activity to another activity in kotlin

前端 未结 7 882
北恋
北恋 2020-12-03 10:13

As I\'m learning Kotlin for Android development, I\'m now trying the basic programs like hello world and how to navigate from one activity to another activity , there is no

7条回答
  •  青春惊慌失措
    2020-12-03 11:02

    Send value from HomeActivity

    val intent = Intent(this@HomeActivity,ProfileActivity::class.java)
    intent.putExtra("Username","John Doe")
    startActivity(intent)
    

    Get values in ProfileActivity

    val profileName=intent.getStringExtra("Username")
    

提交回复
热议问题