本文介紹了如何在對話框顯示時隱藏鍵盤?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!
問題描述
我有一個自定義對話框,其中包含 EditText.當對話框出現時,焦點在 EditText 上,并且顯示了軟鍵盤.如何避免這種情況?我試過了:
I have a custom dialog with a EditText in it. When the dialog appear the focus is on the EditText, and the soft keyboard is showing. How to avoid this? I tried:
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
和
InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(edittext.getWindowToken(), 0);
但它們對我不起作用.我認為這些不適用于對話.
but they don't work for me. I think these don't work for dialog.
推薦答案
你試過了嗎?我已經測試過了.它工作正常.
Have u tried this?I have tested it.It is working.
改變
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
收件人
dialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
這篇關于如何在對話框顯示時隱藏鍵盤?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!
【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!