Use startActivity within a View in Kotlin Android

2

To open a activity from another activity use

startActivity(Intent(this, SegundaActivity::class.java)

But it's not like referring to the this when I want to launch it when I press a button ... in java I indicate it with MainActivity.this but in Kotlin it is not how you can refer to the mother activity.

fab.setOnClickListener { view ->
    startActivity(Intent(???this???, SegundaActivity::class.java)
}
    
asked by Webserveis 14.05.2018 в 12:08
source

1 answer

2
startActivity(Intent([email protected],RequiredClassName::class.java)

Your code would look something like this:

fab.setOnClickListener { view ->
    startActivity(Intent([email protected],ClassName::class.java))
}
    
answered by 14.05.2018 / 12:20
source