编辑字段时如何打开与文本字段关联的虚拟键盘?
我在 startApp()
中初始化了 VKBImplementationFactory
:
public void startApp() {
VKBImplementationFactory.init();
Display.init(this);
new MenuPrincipalForm(this).show();
}
我还在表单中创建了一个 VirtualKeyboard :
...
private VirtualKeyboard vkNombre = new VirtualKeyboard();
...
vkNombre.setInputModeOrder(new String[]{VirtualKeyboard.NUMBERS_SYMBOLS_MODE});
并且我将此 VirtualKeyboard 绑定到了一个 TextField :
cintxt=new TextField();
VirtualKeyboard.bindVirtualKeyboard(cintxt, vkNombre);
我注册了 dataChangeListener
> 到此 TextField :
public class ModifierFicheClient extends Form implements ActionListener, DataChangedListener
{
...
cintxt.addDataChangeListener(this);
...
}
在 dataChanged(int type, int index)
方法中,我想打开 vkNombre
VirtualKeyBoard。我知道,当单击 TextField
时,会自动显示 VirtualKeyboard
。但有一种情况是,当通过手机移动滚动软按钮导航到 TextField
时,我可以导航到 TextField
而无需单击它,并且我可以输入任何字母!那么在手机上打字时如何调用VirtualKeyboard
呢?
注意:我在 dataChanged(int type, int index)
方法中编写了 System.out.println("zzzz");
,并且输出写入两行“zzzz”我输入一个字符
!那么为什么当我只输入一个字母时,dataChanged
方法会被调用两次
?
I initialized the VKBImplementationFactory
in startApp()
:
public void startApp() {
VKBImplementationFactory.init();
Display.init(this);
new MenuPrincipalForm(this).show();
}
I created also a VirtualKeyboard in a Form :
...
private VirtualKeyboard vkNombre = new VirtualKeyboard();
...
vkNombre.setInputModeOrder(new String[]{VirtualKeyboard.NUMBERS_SYMBOLS_MODE});
And I bound this VirtualKeyboard to a TextField :
cintxt=new TextField();
VirtualKeyboard.bindVirtualKeyboard(cintxt, vkNombre);
I registered dataChangeListener
to this TextField :
public class ModifierFicheClient extends Form implements ActionListener, DataChangedListener
{
...
cintxt.addDataChangeListener(this);
...
}
In the dataChanged(int type, int index)
method I want to open the vkNombre
VirtualKeyBoard. I know that when clicking the TextField
then the VirtualKeyboard
is shown automatically. But there is a case when navigating to the TextField
through the phone mobile scroll softbuttons then I can navigate to the TextField
without clicking it and I can type any letters ! So how to call the VirtualKeyboard
when typing a letter on the phone mobile ?
NB : I wrote System.out.println("zzzz");
in the dataChanged(int type, int index)
method and the output writes two lines "zzzz" when I type one character
! So why the dataChanged
method is called two times
when I type only one letter ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
无需在
startApp()
中使用VKBImplementationFactory.init();
。因为LWUIT会自动检测该手机是否是触摸屏。当您使用 LWUIT 1.5 或之前的版本时,数字约束在VKB
上不起作用。这是该版本的错误。但它将在 LWUIT 的当前存储库版本< /a>(修订版:1605)。因此,您可以从存储库中签出并使用最新的 LWUIT jar。更新:
请参阅显示
VKB
的示例代码,同时关注TextField
,No need to use
VKBImplementationFactory.init();
instartApp()
. Because LWUIT automatically detect whether that mobile is touch screen or not. And numeric constraint not working onVKB
when you use LWUIT 1.5 or before versions. It is bug on that versions. But it will be fixed on current repository version of LWUIT (Revision: 1605). So you can checkout from repository and use the latest LWUIT jar.Update:
See the sample code for showing
VKB
while focusing onTextField
,