Myat Min Soe
Myat Min Soe

Reputation: 807

Get text from keyOutputText android

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.

Upvotes: 0

Views: 597

Answers (1)

cuihao
cuihao

Reputation: 348

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.

Upvotes: 2

Related Questions