更新时间:2023-02-06 22:35:33
这原来是非常可行的,和我最初的问题,可能有更多的是与一般的Android newbiness(这是我的第一个Android应用程序),而不是KeyboardView 。特别是,我已经习惯了知名度是一个简单的二元属性。
This turns out to be very doable, and my initial problems probably had more to do with general Android newbiness (this is my first Android app) and not the KeyboardView. In particular, I'm used to visibility being a simple binary property.
总之:
KeyboardView
与XML文件的android:知名度=水涨船高
setKeyboard()
附加键盘。这一点很重要,因为 KeyboardView
从键盘获取其大小。 KeyboardView.setOnKeyboardActionListener()
。从对话框
回到我的主查看
,我把 OnKeyboardActionListener 在一个独立的类的功能,但是,这是没有必要的。
keyboardView.setEnabled(真);
。这似乎并不为必要,但我不知道(但)在什么情况下会的问题;的也许的只有当你调用的setEnabled(假)
。 keyboardView.set previewEnabled(真);
- 这是非常有用的,如果用户不会从一个输入BIOX正上方获得视觉反馈键盘。 keyboardView.setVisibility(可见);
KeyboardView
in your XML file with android:visibility="gone"
.setKeyboard()
to attach a keyboard. This is important, as the KeyboardView
gets its size from the keyboard.KeyboardView.setOnKeyboardActionListener()
. After refactoring this functionality from a Dialog
back to my main View
, I put the OnKeyboardActionListener
functionality in a stand-alone class, but this is not necessary.keyboardView.setEnabled(true);
. This does not seem to be necessary, but I am not sure (yet) under what circumstances it would matter; perhaps only if you call setEnabled(false)
.keyboardView.setPreviewEnabled(true);
- this is especially useful if the user won't be getting visual feedback from an input biox right above the keyboard.keyboardView.setVisibility(VISIBLE);
.要隐藏键盘在适当的时候,只需拨打 keyboardView.setVisibility(GONE);
。要改变键盘(如在一个shift键,或周期通过的非符号键盘按键,只需拨打 setKeyboard
一次。我用地图<<整数,键盘>
来实现一个懒惰的创建模式;弱引用可能是可取的,如果该程序会长时间运行,键盘不会有太大使用
To hide the keyboard when appropriate, just call keyboardView.setVisibility(GONE);
. To change the keyboard (as on a shift key, or a cycle-through-the-symbol-keyboards key, just call setKeyboard
again. I use a Map<<Integer, Keyboard>
to implement a lazy-create pattern; a weak reference may be desirable, if the program will run for a long time and the keyboard will not be used much.