I had tried almost every method I searched.But for some keyboard like TouchPal,Swype these methods didn't work.
imeOptions
<EditText android:imeOptions="actionSend"/>
setOnKeyListener
dispatchKeyEvent
onEditorAction
And I also find this Enter key listener for Google keyboard is not working
So I use this , it really worked.
if (isPressEnterSendMsg) {
if (s == null)
return;
String str = s.toString().substring(start, start + count);
if (str.equals("\n")) {
chatEditContent.setText(s.toString().replaceFirst("\n", ""));
chatSendButton.performClick();
return;
}
}
With the app testing,I found it's ok when I input normal message include small expression,when include SpannableString I press enter , the s in method onTextChanged(CharSequence s, int start, int before, int count) will be "".
Then I found I cannot setText in onTextChanged method,I searched agin,I can removeTextChangedListener in onTextChanged and then addTextChangedListener,But didn't work...
So I want to ask if there any other solution I can do ?
Thanks!