Kotlin Android start new Activity

后端 未结 17 2315
不知归路
不知归路 2020-12-07 23:33

I want to start another activity on Android but I get this error:

Please specify constructor invocation; classifier \'Page2\' does not have a companio

17条回答
  •  余生分开走
    2020-12-08 00:39

    You have to give the second argument of class type. You can also have it a little bit more tidy like below.

    startActivity(Intent(this, Page2::class.java).apply {
        putExtra("extra_1", value1)
        putExtra("extra_2", value2)
        putExtra("extra_3", value3)
    })
    

提交回复
热议问题