我不希望显示的虚拟键盘。
I don't want to show the virtual keyboard.
我试过下面的方法,但它并没有任何区别。
I tried the below method but it doesn't make any difference.
InputMethodManager imm = InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(enter_count.getWindowToken(), 0);
enter_count是我的编辑文本 我曾尝试在InputMethod经理读了,但不能跟着它。
enter_count is my edit text I have tried reading up on the InputMethod Manager but can't follow it.
我可以将我的编辑文本的输入类型称为enter_count如下:
I can set the input type of my edit text called enter_count as follows
enter_count.setInputType( InputType.TYPE_NULL );
但我不能指定只接受数字输入
but then I can't specify to only accept numeric input
能否请你给我一个合理的解决方案根本就没有,而不会丢失只接受了物理键盘上输入数字的能力,显示虚拟键盘。
Can you please give me a reasonable solution to simply not show the virtual keyboard without losing the ability to only accept numeric input on the physical keyboard.
这个怎么样?
EditText editText = (EditText) findViewById(R.id.edt_hello);
editText.setKeyListener(new NumberKeyListener() {
@Override
public int getInputType() {
return InputType.TYPE_NULL;
}
@Override
protected char[] getAcceptedChars() {
return new char[] { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9' };
}
});