0

Hi I am developing a custom keyboard and I used android:keyOutputText="" in keyboard xml. How to get that text within java class? I only found how to use android:codes to use with decimal codes.

Myat Min Soe
  • 787
  • 8
  • 32

1 Answers1

2

I had a try. You can catch keyOutputText in the onText method of your overridden implementation of OnKeyboardActionListener. Like this:

public class MyOnKeyboardActionListener implements OnKeyboardActionListener {
    @Override
    public void onKey(int primaryCode, int[] keyCodes) {
        // handle key code
    }

    @Override
    public void onText(CharSequence text) {
        Log.d("DEBUG", "input text: " + text);
    }

    @Override public void onPress(int primaryCode) { }
    @Override public void onRelease(int primaryCode) { }
    @Override public void swipeLeft() { }
    @Override public void swipeRight() { }
    @Override public void swipeDown() { }
    @Override public void swipeUp() { }
}

It seems keys with keyOutputText setting won't trigger onKey method when pressed.

cuihao
  • 351
  • 2
  • 12