标签:
EditText添加焦点监听事件,当该EditText失去焦点时,关闭键盘。
EditText editTextProfileName = (EditText) view .findViewById(R.id.nameEditText); editTextProfileName.setOnFocusChangeListener(new OnFocusChangeListener() { public void onFocusChange(View v, boolean hasFocus) { if (!hasFocus) { hideKeyboard(); } } private void hideKeyboard() { if (editTextProfileName != null) { InputMethodManager imanager = (InputMethodManager) getActivity() .getSystemService(Context.INPUT_METHOD_SERVICE); imanager.hideSoftInputFromWindow(editTextProfileName.getWindowToken(), 0); } } });
学习自:http://stackoverflow.com/questions/17184119/how-to-hide-soft-key-pad-after-changing-one-viewpager-to-another-view-pager
标签:
原文地址:http://www.cnblogs.com/xuepeng0521/p/5822521.html