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

前端 未结 7 880
北恋
北恋 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 10:52

    In Kotlin, you can pass the data simply by using the Intents. You can directly put your data in intent or you can write those data in bundle and send that bundle to another activity using the intent.

    val intent = Intent(this@HomeActivity,ProfileActivity::class.java);
    intent.putExtra("profileName", "John Doe")
    var b = Bundle()
    b.putBoolean("isActive", true)
    intent.putExtras(b)
    startActivity(intent);
    

提交回复
热议问题