我在Android项目上创建了自己的键盘,效果很好;这里有一小段代码:
mKeyboard = new Keyboard(this, R.layout .keyboard);
mKeyboardView = (CustomKeyboardView) findViewById(R.id.KeyboardArea);
mKeyboardView.setKeyboard(mKeyboard);
每当用户触摸我的Activity的editText时,我都会显示它。我的问题是,如果我按下我的仿真器键盘的中央按钮,标准键盘仍然有效...此外,尽管我把它放在:
android:windowSoftInputMode="adjustResize"
在我的AndroidManifest文件中,但它只适用于标准键盘...所以,是否可以用我自定义的软键盘完全替换系统的软键盘?
答案 0 :(得分:1)
尝试:getWindow()。setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN);
另请参阅:How to stop Soft keyboard showing automatically when focus is changed (OnStart event)
答案 1 :(得分:0)
你这样做....
int lastwidth;
@Override
public void onInitializeInterface() {
if(mKeyboard!=null){
int diswidth = getMaxWidth();
if(lastwidth==diswidth){
return;
}
lastwidth=diswidth;
}
alphakeyb = new Keyboard(this, R.layout.alphakey);
}
@Override
public View onCreateInputView() {
// inflatin keyboardview from xml file
keybview = (KeyboardView) getLayoutInflater().inflate(R.layout.customkeybview,null);
// setting listner on keyboardview
keybview.setOnKeyboardActionListener(this);
// setting keyboard to keyboardview
keybview.setKeyboard(alphakeyb);
return keybview;
}
您还可以参考API演示中的android软键盘示例