Kotlin kotlin.NotImplementedError: An operation is not implemented: not implemented

    对我个人来说,2019 不能不学习Kt了,Google 主推的语言,我不能视而不见,其实专心学下去,很快就能上手,IT 这个行业就是要不停的学习,才不会被淘汰。你停下脚步的那一刻,就是掉队的时候,所以静下心来 ,安静的Coding 就是我的日常生活。

今天学习 Kt 的View onClick 事件,没想到一点击就crash:

kotlin.NotImplementedError: An operation is not implemented: not implemented

代码:

 override fun onClick(p0: View?) {
        TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
        when(p0?.id)
        {
           R.id.tv ->  toast("这是TextView onClick")
        }
    }

crash 原因,没有implement TODO ,解决办法,注释掉TODO:

override fun onClick(p0: View?) {
        //TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
        when(p0?.id)
        {
           R.id.tv ->  toast("这是TextView onClick")
        }
    }

 

你可能感兴趣的:(Kotlin)