我有以下代码,并且Intent出现错误。这是因为我相当确定this
。
listView.onItemClickListener = object : OnItemClickListener {
override
fun onItemClick(parent: AdapterView<*>, view: View,
position: Int, id: Long) {
val intent = Intent(this, MyActivity::class.java)
startActivity(intent)
}
}
最佳答案
您可以使用两种解决方案:
val intent = Intent(this@YourActivity, MyActivity::class.java)
startActivity(intent)
要么 :
val intent = Intent(applicationContext, MyActivity::class.java)
startActivity(intent)
关于android - Kotlin Intent 错误,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/47669712/