2011-11-11 162 views
1

我显示了一个使用AlertDialog的输入框。当我调用AlertDialog.show()时,对话框中的EditText自动对焦,但软键盘不会自动显示。Android键盘没有显示

如何在显示对话框时自动显示软键盘? (并且没有物理/硬件键盘)。与我按搜索按钮调用全局搜索时的方式类似,软键盘会自动显示。

回答

7

你可以试试下面的方法,一旦对话框打开,从here采取:

InputMethodManager inputMethodManager = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE); 
     inputMethodManager.toggleSoftInputFromWindow(linearLayout.getApplicationWindowToken(), InputMethodManager.SHOW_FORCED, 0); 

其他建议here了。

+0

非常感谢它为我工作。 –