kotlin.NotImplementedError: An operation is not implemented: not implemented Error from ImageButton Click

Just remove TODO( ... ) from your onClickListener:

override fun onClick(v: View?) {
    // No TODO here
    when (v?.id) {
        ...
    }
}

TODO(...) is Kotlin function which always throws NotImplementedError. If you want to mark something with TODO but to not throw exception - just use TODO with comments:

override fun onClick(v: View?) {
    //TODO: implement later
    when (v?.id) {
        ...
    }
}

TODO() is an inline function in Kotlin. It ALWAYS will throw NotImplementedError. See #documentation: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-t-o-d-o.html

If you want just to mark that this fragment of code still needs work, use // TODO. Then, the mark will be visible in TODO section, but will not throw exception.


I implemented this

  val extraTime = arrayListOf<String>("1 hour")
    val extraTimeAdapter = CustomSpinDeliveryExtraTimeAdapter(context!!, R.layout
            .simple_spinner_text_middle_down_arrow, extraTime)
    spinCustomTime.adapter = extraTimeAdapter
    spinCustomTime.onItemSelectedListener = object : AdapterView.OnItemSelectedListener {
        override fun onNothingSelected(parent: AdapterView<*>?) {
            TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
        }

        override fun onItemSelected(parent: AdapterView<*>?, view: View?, position: Int, id: Long) {
            TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
        }

    }

After removing todo from this below code

 spinCustomTime.onItemSelectedListener = object : AdapterView.OnItemSelectedListener {
    override fun onNothingSelected(parent: AdapterView<*>?) {

    }

    override fun onItemSelected(parent: AdapterView<*>?, view: View?, position: Int, id: Long) {

    }

}

solved my problem.

Also see this doc link for clarification See #documentation: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-t-o-d-o.html