Here is my problem. I have a custom keyboard that I am dynamically adding keys to but anytime I try to catch the keys being pressed I don't catch anything useful. The only callback that gets triggered is onPress and it is supposed to have the keys primaryCode as an argument. The problem is that this primary is always 0 even if I try to change it when I create the key. How can I get the primaryCode to reflect the primary code of the key that was pressed?
Here is my keyboard.xml
<Keyboard xmlns:android="http://schemas.android.com/apk/res/android"
android:keyWidth="25%p"
android:keyHeight="10%p">
</Keyboard>
This is where I generate my keyboard keys, which works great. My keyboard looks exactly how it is supposed to.
Keyboard.Row row = new Row(this);
for (int i = 0; i < labels.size(); i++) {
Keyboard.Key key = new Keyboard.Key(row);
key.label = labels.get(i);
key.text = labels.get(i);
key.codes = new int[] { 'c' };
key.width = keyWidth;
key.height = keyHeight;
this.getKeys().add(key);
}
And I register for the listener in my fragment.
keyboardView.setOnKeyboardActionListener(this);
The problem was that I didn't have stub rows and keys in my keyboard.xml file. After adding them the issue was resolved.