【问题标题】:My Emoji Soft Keyboard is not supporting for Message EditText Field in android我的 Emoji 软键盘不支持 android 中的 Message EditText Field
【发布时间】:2015-09-19 12:48:14
【问题描述】:

我的 Emoji 软键盘不支持 android 中的 Message Edittext Field。 但确实支持 WhatsApp 等其他应用程序。 例如,在 whatsapp 和微信应用程序中,TextField 确实支持 Emoji 键盘字符,但在我的移动消息 TextField 中它显示?或 _ 对于我使用表情符号软键盘键入的每个字符。 我想在 Android 应用程序的 Mobile Messaging EditText 字段中集成 Emoji 字符支持。

如果有人可以给我解决这个问题的方法,我将非常感谢你的回答。

【问题讨论】:

    标签: android unicode android-softkeyboard emoji emoticons


    【解决方案1】:

    找到解决办法:

    我是我的 unicode 我将 'U+' 替换为 '0x'

    示例:将“U+1F60A”替换为“0x1F60A”

    这样我得到了一个“int”:

    int unicode = 0x1F60A;
    String text = String.valueOf(Character.toChars(unicode));
    inputConnection.commitText(text, mComposing.length());
    

    看我的 GSM 消息文本版本 android 4.2.x:

    看我的另一条消息文本版本android 4.4.2

    这里显示另一个像这样的文本框:

    试试http://apps.timwhitlock.info/emoji/tables/unicode

    【讨论】:

      【解决方案2】:

      试试看:

      int unicode = 0x1F60A;
                          String text = String.valueOf(Character.toChars(unicode));
                          //inputConnection.commitText(text,mComposing.length());
                          mComposing.append(text);
                          sss.append(text);
                          commitTyped(getCurrentInputConnection());
      

      【讨论】:

        【解决方案3】:

        另一个答案:

        public void onKey(int primaryCode, int[] keyCodes) {
                if (primaryCode == -100000) {
                    int unicode = 0x1F349;
                    String text = String.valueOf(Character.toChars(unicode));
                    mComposing.append(text);
                    commitTyped(getCurrentInputConnection());
                } else if (isWordSeparator(primaryCode)) {
                    if (mComposing.length() > 0) {
                        commitTyped(getCurrentInputConnection());
                    }
                    sendKey(primaryCode);
                    updateShiftKeyState(getCurrentInputEditorInfo());
                } else if (primaryCode == Keyboard.KEYCODE_DELETE) {
                    handleBackspace();
                } else if (primaryCode == Keyboard.KEYCODE_SHIFT) {
                    handleShift();
                } else if (primaryCode == Keyboard.KEYCODE_CANCEL) {
                    handleClose();
                    return;
                } else if (primaryCode == LatinKeyboardView.KEYCODE_OPTIONS) {
                    // Show a menu or somethin'
                } else if (primaryCode == Keyboard.KEYCODE_MODE_CHANGE && mInputView != null) {
                    Keyboard current = mInputView.getKeyboard();
                    if (current == mSymbolsKeyboard || current == mSymbolsShiftedKeyboard) {
                        current = mQwertyKeyboard;
                    } else {
                        current = mSymbolsKeyboard;
                    }
                    mInputView.setKeyboard(current);
                    if (current == mSymbolsKeyboard) {
                        current.setShifted(false);
                    }
                } else {
                    handleCharacter(primaryCode, keyCodes);
                }
            }
        

        【讨论】:

          【解决方案4】:

          只需将您的 Emoji xml 代码设置为用户定义(111222) 例如-

          <key android:codes="111222" android:keyIcon="@drawable/smiley"/>
          

          然后软键盘中的 onkey() 方法实现如下:

          public void onKey(int primaryCode, int[] keyCodes){
          
          ----
          ----   
          
          else if(primaryCode == 111222){
              int codeOfEmoji= 0x1F60A;
                  String text = String.valueOf(Character.toChars(codeOfEmoji));
                                  mComposing.append(text);
                                  sss.append(text);
                                  commitTyped(getCurrentInputConnection());
              }
          ----
          ----
          }
          

          这个过程会做每一个表情符号集。这是处理这个问题的非常简单的过程。

          【讨论】:

          • mComposing、sss 和 commitTyped 无法解析。什么是主题类型?
          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 2015-12-18
          • 1970-01-01
          • 2011-10-17
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多