Modifying the keyboard in Android



You can show and hide rows - kind of. You can't actually modify a keyboard after you've instantiated it with the new keyword. Instead, you can modify it at the time of instantiation:
 
new Keyboard(this, R.xml.keyboard_layout, R.integer.keyboard_show_extra_row)

I put the constant keyboard_show_extra_row in a file called keyboard.xml, but you can actually call that file anything as long as it's in the values folder:

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <integer name="
keyboard_show_extra_row">1</integer>
</resources>


and add the constant to the rows that you want controlled by this constant:

<Row android:keyboardMode="@integer/keyboard_suggestions">
    ...

</Row>

Then you just instantiate as described above.

Modifying after instantiating

Apparently you can't modify after instantiation. However, you can create two copies, one created with this flag and one without. You can then switch between them with the setKeyboard method.

Comments

Popular posts from this blog

Available Resources for Android

Using React Native in an Android Custom Keyboard

Popup Keyboard for Special Characters in Android