I'm developing a chat app, and looking for a way to catch ENTER is pressed on soft keyboard during message editing (in an EditText). The aim is to send the text directly. Obviously I also have implemented a "SEND" button.
Two attempts:
using
editText.addTextChangedListener(new TextWatcher()..
Result: I get "\n" character either in onTextChanged and afterTextChanged
callbacks. I could "remove" this character and send chat, but I don't like
this way.using
editText.setOnEditorActionListener(new TextView.OnEditorActionListener()..
Result: It doesn't work.
Any better solution?