Skip to content

Instantly share code, notes, and snippets.

@shkschneider
Created May 21, 2019 10:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shkschneider/c18d06fd4641afa908108d18da5d1b19 to your computer and use it in GitHub Desktop.
Save shkschneider/c18d06fd4641afa908108d18da5d1b19 to your computer and use it in GitHub Desktop.
fun EditText.setOnKeyboardSubmitListener(block: () -> Unit) {
setOnEditorActionListener { _, actionId, _ ->
if (actionId == EditorInfo.IME_ACTION_DONE) {
block()
true // implicit and won't do anything
// should use return@setOnEditorActionListener
}
false // explicit
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment