一、强制弹出:
默认情况下Android 的EditView 是可以弹出软件盘的,但是有时候却不可以,解决办法:
private EditText et;
et.setCursorVisible(false);//将光标隐藏 et.setFocusable(true); et.requestFocus();
public void showSoftInputFromWindow() { et.setFocusable(true); Timer timer = new Timer(); timer.schedule(new TimerTask() { public void run() { InputMethodManager inputManager = (InputMethodManager) et.getContext().getSystemService(Context.INPUT_METHOD_SERVICE); inputManager.showSoftInput(et, 0); } }, 500); }
参考文档:http://blog.csdn.net/zice_/article/details/51769354
二、隐藏软键盘
InputMethodManager imm = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE); imm.showSoftInput(view,InputMethodManager.SHOW_FORCED); imm.hideSoftInputFromWindow(view.getWindowToken(), 0); //强制隐藏键盘
参考:http://blog.csdn.net/cshichao/article/details/8536961