0

I had tried almost every method I searched.But for some keyboard like TouchPal,Swype these methods didn't work.

  1. imeOptions

    <EditText android:imeOptions="actionSend"/>

  2. setOnKeyListener

  3. dispatchKeyEvent

  4. 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!

Emma Han
  • 1
  • 1

0 Answers0