0
當我點擊編輯框softkeyboard顯示。但它不會隱藏當編輯框失去焦點。我在我的app.i使用片段已嘗試下面的代碼來隱藏keyborad。如何在片段交易時隱藏軟鍵盤?
public void onActivityCreated(Bundle arg0) {
super.onActivityCreated(arg0);
_context = this.getActivity();
InputMethodManager imm = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
if (imm != null)
imm.hideSoftInputFromWindow(getView().getWindowToken(), 0);
}
但是應用程序間歇性地崩潰.logcat錯誤如下。
05-04 18:22:15.540: E/AndroidRuntime(8152): java.lang.IllegalStateException: Recursive entry to executePendingTransactions
05-04 18:22:15.540: E/AndroidRuntime(8152): at android.support.v4.app.FragmentManagerImpl.execPendingActions(Unknown Source)
05-04 18:22:15.540: E/AndroidRuntime(8152): at android.support.v4.app.FragmentManagerImpl$1.run(Unknown Source)
請人幫我做這件事......