Kotlin Spinner OnItemSelected 意图

Kotlin Spinner OnItemSelected Intent

大家好,我创建了一个包含三个选项的微调器。现在我希望用户决定一个选项。然后用户应该被引导到配件 activity。但是我通过向选定的项目添加 Intent 方法而出错。所以它“不知道”函数类型

option.onItemSelectedListener = object: AdapterView.OnItemSelectedListener {
            override fun onItemSelected(p0: AdapterView<*>?, p1: View?, p2: Int, p3: Long) {
                result.text = options.get(p2)
                if (options.get(p2) == "3 Rounds") {
                    val intent = Intent(this, Settings::class.java)
                    startActivity(intent)
                }
            }

            override fun onNothingSelected(p0: AdapterView<*>?) {
                result.text = "Please Select"
            }
        }

当我按下 Alt + Enter 时,它只是说要创建一个函数。

在 Kotlin 中,您必须在 this 关键字之后提及您的 Activity 名称,然后是 @

val intent = Intent(this@YourActivity, Settings::class.java)