[英]How to force to show and hide virtual Keyboard if no hardware keyboard is available?
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! 谢谢!
我会说使用Configuration类hardKeyboardHidden来查看硬键盘是否已经关闭,如果没有,则打开软键盘
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.