我正在使用AlertDialog显示一个输入框.当我调用AlertDialog.show()时,对话框内部的EditText会自动聚焦,但软键盘不会自动显示.
如何在显示对话框时自动显示软键盘?(并且没有物理/硬件键盘).与按下"搜索"按钮调用全局搜索的方式类似,将自动显示软键盘.
你可以试试下面的方法,一旦对话框打开,取自这里:
InputMethodManager inputMethodManager = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
inputMethodManager.toggleSoftInputFromWindow(linearLayout.getApplicationWindowToken(), InputMethodManager.SHOW_FORCED, 0);
Run Code Online (Sandbox Code Playgroud)
这里也有其他建议.
| 归档时间: |
|
| 查看次数: |
2374 次 |
| 最近记录: |