It's been a while since I started learning Kotlin, so I wondered how to write code that I used to write in Java in Kotlin, so I briefly wrote screen transitions using Intent.
There was a slightly different notation from Java, so I've summarized it this time.
Java
Intent intent = Intent(MainActivity.this, SecondActivity.class)
startActivity(intent)
This was a screen transition using Intent in Java, so in Kotlin,
Kotlin
val intent: Intent = Intent(MainActivity.this, SecondActivity.class)
startActivity(intent)
When I thought that I could go with this, I got an error
After investigating various things,
Kotlin
val intent = Intent(this, SecondActivity::class.java)
startActivity(intent)
This person was able to make a screen transition. It seems that it was simply written incorrectly,
::class.java
The part did not come with a bad pin ...
class.java
I think that part means that it's a Java class, but ...
I will add it as soon as I understand it.
Recommended Posts