本文介紹了在android中輸入EditText后如何隱藏鍵盤?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!
問題描述
我有一個 EditText
和按鈕對齊到父的底部.
I have a EditText
and button aligned to parent's bottom.
當我在其中輸入文本并按下按鈕保存數據時,虛擬鍵盤并沒有消失.
When I enter text in it and press the button to save data, the virtual keyboard does not disappear.
誰能指導我如何隱藏鍵盤?
Can any one guide me how to hide the keyboard?
推薦答案
這應該可行.
InputMethodManager inputManager = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
inputManager.hideSoftInputFromWindow(this.getCurrentFocus().getWindowToken(),InputMethodManager.HIDE_NOT_ALWAYS);
只要確保 this.getCurrentFocus() 不返回 null,如果沒有焦點,它會返回.
Just make sure that this.getCurrentFocus() does not return null, which it would if nothing has focus.
這篇關于在android中輸入EditText后如何隱藏鍵盤?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!
【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!