如何制作动态自定义键盘Android? (编程)

时间:2016-09-30 07:21:07

标签: android dynamic keyboard android-softkeyboard

我尝试从字符串ArrayList(不仅是char)创建一个键盘,但没有一个键盘对象的构造函数允许它。

键盘| Android开发者: https://developer.android.com/reference/android/inputmethodservice/Keyboard.html

源代码:

    mKeyboard = new Keyboard(this, R.xml.keyboard, "", 10, 0);

    Keyboard.Row row = new Keyboard.Row(mKeyboard);
    row.defaultHeight = 108;
    row.defaultWidth = 150;
    row.defaultHorizontalGap = 0;
    row.verticalGap = 0;
    row.rowEdgeFlags = mKeyboard.EDGE_BOTTOM | mKeyboard.EDGE_TOP;

    Keyboard.Key key = new Keyboard.Key(row);
    key.x = 0;
    key.y = 0;
    key.codes = new int[]{1};
    key.label = "test";

    Keyboard.Key key1 = new Keyboard.Key(row);
    key1.x = 150;
    key1.y = 0;
    key1.width = 300;
    key1.codes = new int[]{2};
    key1.label = "test1";

    mKeyboard.getKeys().add(key);
    mKeyboard.getKeys().add(key1);

我无法访问属性以更改键盘尺寸。

有没有人能解决我的问题?

0 个答案:

没有答案