Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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