//隐藏输入法
popupInputWindow(et_sns,getActivity());
/** * 强制隐藏 */public static void popupInputWindow(final EditText editText, final Context context) { editText.postDelayed(new Runnable() { @Override public void run() { InputMethodManager imm = (InputMethodManager)context.getApplicationContext().getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(editText.getWindowToken(), 0); //制隐藏键盘 } }, 0);}
弹出输入法
openKeyboard();
/** * 打开软键盘 */private void openKeyboard() { Timer timer = new Timer(); timer.schedule(new TimerTask() { @Override public void run() { InputMethodManager imm = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE); imm.toggleSoftInput(0, InputMethodManager.HIDE_NOT_ALWAYS); } }, 200);}