EmojiEditTextHelper

public final class EmojiEditTextHelper
extends Object

java.lang.Object
   ↳ androidx.emoji.widget.EmojiEditTextHelper


Utility class to enhance custom EditText widgets with EmojiCompat.

 public class MyEmojiEditText extends EditText {
      public MyEmojiEditText(Context context) {
          super(context);
          init();
      }
      // ...
      private void init() {
          super.setKeyListener(getEmojiEditTextHelper().getKeyListener(getKeyListener()));
      }

      @Override
      public void setKeyListener(android.text.method.KeyListener keyListener) {
          super.setKeyListener(getEmojiEditTextHelper().getKeyListener(keyListener));
      }

      @Override
      public InputConnection onCreateInputConnection(EditorInfo outAttrs) {
          InputConnection inputConnection = super.onCreateInputConnection(outAttrs);
          return getEmojiEditTextHelper().onCreateInputConnection(inputConnection, outAttrs);
      }

      private EmojiEditTextHelper getEmojiEditTextHelper() {
          if (mEmojiEditTextHelper == null) {
              mEmojiEditTextHelper = new EmojiEditTextHelper(this);
          }
          return mEmojiEditTextHelper;
      }
 }
 

Summary

Public constructors

EmojiEditTextHelper(EditText editText)

Default constructor.

Public methods

KeyListener getKeyListener(KeyListener keyListener)

Attaches EmojiCompat KeyListener to the widget.

int getMaxEmojiCount()

Returns the maximum number of EmojiSpans to be added to a CharSequence.

InputConnection onCreateInputConnection(InputConnection inputConnection, EditorInfo outAttrs)

Updates the InputConnection with emoji support.

void setMaxEmojiCount(int maxEmojiCount)

Set the maximum number of EmojiSpans to be added to a CharSequence.

Inherited methods

Public constructors