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

产生原因:

1. TODO

方法声明:

@kotlin.internal.InlineOnly

public inline fun TODO(): Nothing = throw NotImplementedError()

方法使用:

fun test(){

    TODO("Not implemented")

}

方法说明:有点类似于java的//todo,但是不同的是,因为它的方法告诉我们,它会抛出一个异常,也就是上面这个方法会导致程序崩溃。它的好处是:配合IDE自动声明的TODO, 会强制开发者去实现这个TODO或者删除它。

我出该异常时的代码:在给EditText添加一个addTextChangedListener监听时,以为和平时写Java的时候,不用管TODO,也就没有注释掉,在Kotlin代码上,运行就出现了NotImplementedError异常.所以要解决这个问题,值需要删除掉TODO就可以了.

如下:(删除TODO即可)

override fun onActivityPaused(activity: Activity?) {

TODO("not implemented")//To change body of created functions use File | Settings | File Templates.

}

override fun onActivityResumed(activity: Activity?) {

TODO("not implemented")//To change body of created functions use File | Settings | File Templates.

}

override fun onActivityStarted(activity: Activity?) {

TODO("not implemented")//To change body of created functions use File | Settings | File Templates.

}

override fun onActivityDestroyed(activity: Activity?) {

TODO("not implemented")//To change body of created functions use File | Settings | File Templates.

}

override fun onActivitySaveInstanceState(activity: Activity?, outState: Bundle?) {

TODO("not implemented")//To change body of created functions use File | Settings | File Templates.

}

override fun onActivityStopped(activity: Activity?) {

TODO("not implemented")//To change body of created functions use File | Settings | File Templates.

}

override fun onActivityCreated(activity: Activity?, savedInstanceState: Bundle?) {

TODO("not implemented")//To change body of created functions use File | Settings | File Templates.

}

你可能感兴趣的:(kotlin.NotImplementedError: An operation is not implemented: not implemented)