2011-09-16 53 views
5

我的应用程序需要有两个输入源同时激活:条码扫描器和软键盘。当我配对蓝牙扫描仪时,它被视为物理键盘。因此,连接此设备时,软键盘未显示(软键盘已停用)。物理键盘和软键盘可以同时处于活动状态吗?

物理键盘和软键盘可以同时处于活动状态吗? 如果不是,解决问题的最佳方法是什么?我是否必须实现一个自定义视图,以吸收按键事件?市场上有没有任何键盘应用程序可以做到这一点?

如何以编程方式打开和关闭物理键盘?这是切换按钮“使用物理键盘”设置(我发现这个设置在这里的截图:

enter image description here

回答

1

这是不可能同时拥有物理键盘和软键盘在同一时间积极它是通过InputMethodService功能onEvaluateInputViewShown执行。你可以查看文档here

/** 
* Override this to control when the soft input area should be shown to 
* the user. The default implementation only shows the input view when 
* there is no hard keyboard or the keyboard is hidden. If you change what 
* this returns, you will need to call {@link #updateInputViewShown()} 
* yourself whenever the returned value may have changed to have it 
* re-evaluated and applied. 
*/ 
public boolean onEvaluateInputViewShown() { 

所以,除非你实现你自己的IME其中,你可以在此改变onEvaluateInputViewShown它是不可能同时拥有物理和softkeyboard是活跃在同一时间。

关于你最后一个问题,我不确定,但我认为没有办法以编程方式隐藏hardKeyboard。虽然它没有解决方案,但您应该检查this question

相关问题