我想在我的活动中禁用键盘弹出。在活动中不会有任何键盘。但硬件键盘必须工作。如何做到这一点?硬件按钮必须工作
答案 0 :(得分:1)
试试以下代码。
InputMethodManager inputManager = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE);
inputManager.hideSoftInputFromWindow(editView.getWindowToken(), 0);
答案 1 :(得分:1)
在你的清单中使用它:
<activity android:name=".SampleActivity" android:windowSoftInputMode="stateAlwaysHidden"/>
答案 2 :(得分:0)
在Android中管理软键盘并不是那么容易,尽管你可以以编程方式隐藏键盘。
private void hideKeyboard() {
//This will get any view in focus.
View view = this.getCurrentFocus();
if (view != null) {
InputMethodManager inputManager = (InputMethodManager) this.getSystemService(Context.INPUT_METHOD_SERVICE);
inputManager.hideSoftInputFromWindow(view.getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
}
}
请注意硬件键盘可以正常工作。