本文介绍了Kotlin Intent语法错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试在Android Studio的Kotlin中设置Intent
来启动另一个Activity.kt
:
Im trying to set Intent
in Kotlin in Android Studio to launch another Activity.kt
:
val i : Intent = Intent(this, MainActivity::class.java)
Android Studio向我显示一个错误,并且无法编译:
Android Studio shows me an error, and it doesnt compile:
Error:(23, 26) None of the following functions can be called with the arguments supplied:
public constructor Intent(p0: Context!, p1: Class<*>!) defined in android.content.Intent
public constructor Intent(p0: String!, p1: Uri!) defined in android.content.Intent
我认为语法是正确的,那怎么了?
I think syntax is correct, so what is wrong?
推荐答案
val i = Intent(this @ MainActivity,Activity :: class.java)
val i = Intent(this@MainActivity, Activity::class.java)
这篇关于Kotlin Intent语法错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!