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.
Asked
Active
Viewed 573 times
0
-
possible duplicate of [How to develop a soft keyboard for Android?](http://stackoverflow.com/questions/3480715/how-to-develop-a-soft-keyboard-for-android) – Dhinakaran Thennarasu Mar 17 '15 at 07:28
-
it only shows how to use with android:codes decimal codes. I want to use keyOutputText – Myat Min Soe Mar 17 '15 at 07:34
1 Answers
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