2011-11-11 161 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

非常感謝它爲我工作。 –