如何让我的Andr​​oid应用程序编程显示键盘

问题描述:

有没有办法以编程方式告诉机器人打开键盘时,被一个EditText获得的焦点?

Is there any way to programmatically tell android to open the keyboard when the focus is obtained by an EditText?

另外,有没有办法告诉它打开数字键盘?

Also is there any way to tell it to open the numeric keyboard?

谢谢 维克多

要的显示的键盘:

InputMethodManager inputMethodManager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
inputMethodManager.showSoftInput(viewToEdit, 0);

要的隐藏的键盘:

if (getCurrentFocus() != null) {
    inputMethodManager.hideSoftInputFromWindow(getCurrentFocus().getApplicationWindowToken(), 0);
}