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

前端 未结 7 853
北恋
北恋 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:15

    first you should do this,

    var userName = username.text.toString()
    var password = password_field.text.toString()
    

    Add Anko dependency.

     implementation "org.jetbrains.anko:anko:0.10.4"
    

    information passing inside MainActivity() is like

    startActivity<SecondActivity>("Username" to userName,"Password" to password )
    

    get information from SecondActivity() is,

    val profileName=intent.getStringExtra("Username")
    
    0 讨论(0)
提交回复
热议问题