Search code examples
androidkotlinonclicklistener

Android Kotlin : What does return@onClicklistener does?


What does return@onClicklistener does in the below mentioned code

if (password.isEmpty()) {
    Toast.makeText(this@MainActivity, "Missing password", Toast.LENGTH_SHORT).show()
    return@OnClickListener

Solution

  • return@OnClickListener means that the OnClickListener which is set on the View shouldn't execute the code after this statement, but outside the OnClickListener the flow will still remain the same.

    Does that answer your question? :)