本文介紹了如何在對(duì)話框顯示時(shí)隱藏鍵盤?的處理方法,對(duì)大家解決問(wèn)題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)吧!
問(wèn)題描述
我有一個(gè)自定義對(duì)話框,其中包含 EditText.當(dāng)對(duì)話框出現(xiàn)時(shí),焦點(diǎn)在 EditText 上,并且顯示了軟鍵盤.如何避免這種情況?我試過(guò)了:
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);
但它們對(duì)我不起作用.我認(rèn)為這些不適用于對(duì)話.
but they don't work for me. I think these don't work for dialog.
推薦答案
你試過(guò)了嗎?我已經(jīng)測(cè)試過(guò)了.它工作正常.
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);
這篇關(guān)于如何在對(duì)話框顯示時(shí)隱藏鍵盤?的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!
【網(wǎng)站聲明】本站部分內(nèi)容來(lái)源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問(wèn)題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請(qǐng)聯(lián)系我們刪除處理,感謝您的支持!