The expression cannot be a selector(occur after a dot)下面是 what went wrong: Execution failed for task
生活随笔
收集整理的這篇文章主要介紹了
The expression cannot be a selector(occur after a dot)下面是 what went wrong: Execution failed for task
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
這個(gè)是Kotlin 寫跳轉(zhuǎn) 界面的時(shí)候出現(xiàn)的問題使用不對,可以看下跳轉(zhuǎn)的地方this 是否有紅色的橫線提示錯(cuò)誤
正確的寫法如下:
val intent = Intent( this,MainActivity::class.java)
startActivity(intent)
// 或者
startActivity(Intent(this, MainActivity::class.java))//注 意 如果在onCrate 里面寫跳轉(zhuǎn),假如當(dāng)前界面為TestActivity 要跳轉(zhuǎn)到MainActivity
// 后面不是當(dāng)前activity.this 是activity@thisval intent = Intent(this@TestActivity,MainActivity::class.java)
startActivity(intent)
// 或者
startActivity(Intent(this@TestActivity, MainActivity::class.java))
這樣就不報(bào)錯(cuò)了
總結(jié)
以上是生活随笔為你收集整理的The expression cannot be a selector(occur after a dot)下面是 what went wrong: Execution failed for task的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Java 打印数组的方法
- 下一篇: 常用的光缆牵引机皮带的型号规格是哪些?