来源:Android 源码 /packages/apps/QuickSearchBox/.../SearchActivity.java
1. Import
import android.view.inputmethod.InputMethodManager;
2. HOWTO
/**
* Hides the input method.
*/
protected void hideInputMethod() {
InputMethodManager imm = (InputMethodManager) getContext().getSystemService(INPUT_METHOD_SERVICE);
if (imm != null) {
imm.hideSoftInputFromWindow(mQueryTextView.getWindowToken(), 0);
}
}
protected void showInputMethodForQuery() {
InputMethodManager imm = (InputMethodManager) getContext().getSystemService(INPUT_METHOD_SERVICE);
if (imm != null) {
imm.showSoftInput(mQueryTextView, 0);
}
}
3. More information of others
默认弹出和按钮点击
http://www.eoeandroid.com/thread-13373-1-1.html