如果没有可用的硬件键盘,如何强制显示和隐藏虚拟键盘?
如何检测手机没有硬件键盘,只有在这种情况下才强制显示虚拟键盘?我怎样才能隐藏它?
我尝试像这样放置焦点,但它不起作用:
View exampleView = (View)findViewById(R.id.exampleBox);
exampleView.requestFocus();
如果我像这样强制使用虚拟键盘,则当硬件键盘可用时,键盘也会出现,这是没有意义的。
InputMethodManager inputMgr = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
inputMgr.toggleSoftInput(0, 0);
最后但并非最不重要的一点是,如何直接显示数字或手机键盘? (不是普通键盘)
有什么想法吗?
谢谢!
How can I detect that the telephone does not have hardware keyboard and only in that case to force showing the virtual one? And how can I hide it?
I tried putting the focus like this but it doesn't work:
View exampleView = (View)findViewById(R.id.exampleBox);
exampleView.requestFocus();
If I force like this the virtual keyboard, the keyboard will appear also when a hardware keyboard is available, which doesn't make sense.
InputMethodManager inputMgr = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
inputMgr.toggleSoftInput(0, 0);
And last but not least, how can I show directly the numerical or phone keyboard? (Not the normal keyboard)
Any idea?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我会说使用配置类hardKeyboardHidden来查看硬键盘是否出来,如果没有则打开软键盘
I would say use the Configuration class hardKeyboardHidden to see if the hard keyboard is out and if not then open the soft keyboard