昨天收到一個bug,描述如下:1 Enter Settings-->Language&input2 Choose personal dictionary3.Choose add in menu4.Input some word and choose personal dictionary[Expected result]The word can be added to dictionary and no any error[Error]The input panel can't hide進入添加使用者字典後編輯並退出,但是input panel不能自動隱藏。這個問題涉及到fragment的概念,關於理解fragment的概念,可以參考http://www.cnblogs.com/mybkn/articles/2455134.html。 添加使用者字典是在UserDictionaryAddWordFragment中進行的,UserDictionaryAddWordFragment繼承於Fragment。\packages\apps\Settings\src\com\android\settings\inputmethod\UserDictionaryAddWordFragment.java在它的onPause()方法中添加如下code: boolean autoHide = getResources().getBoolean(R.bool.auto_hide_keyboard_when_onpause); if (autoHide){www.2cto.com ContexttContext = getActivity(); InputMethodManager imm =(InputMethodManager)getActivity().getSystemService(tContext.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(getActivity().getCurrentFocus().getWindowToken(),0); }其中的R.bool.auto_hide_keyboard_when_onpause這個值在\packages\apps\Settings\res\value下的bool.xml中定義。smart-phone的這個值是false,value-sw600dp目錄下的bool.xml中的值為true。Fragment的onPause方法是在看不見這個Fragment的時候被調用的,所以把這段code加在onPause方法中即可實現退出這個Fragment時自動隱藏IME介面。