1. //Hide the soft keyboard
((InputMethodManager)getSystemService(INPUT_METHOD_SERVICE)).hideSoftInputFromWindow(WidgetSearchActivity.this.getCurrentFocus().getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
2. //Display the soft keyboard, the control ID can be EditText, TextView
((InputMethodManager)getSystemService(INPUT_METHOD_SERVICE)).showSoftInput(control ID, 0);
3. Do not automatically pop up the keyboard:
With the EditText control, it will automatically gain focus and pop up the keyboard when it is displayed for the first time. If you do not want the keyboard to pop up automatically, there are two options Method one:
Method 1: Set the corresponding activity in the mainfest file
android:windowSoftInputMode="stateHidden" or android:windowSoftInputMode="stateUnchanged".
Method 2: You can put a hidden TextView in the layout, and then requsetFocus during onCreate.
Note that TextView should not set Visiable=gone, otherwise it will be invalid.
You can put a hidden TextView in the layout, and then requsetFocus during onCreate.
Note TextView. Do not set Visiable = gone, otherwise it will fail
# & lt; textView
android: ID = "@+ID/text_notuse"
## android :layout_width="wrap_content" android:layout_height="wrap_content" android:focusable="true"android:focusableInTouchMode="true" /> TextView textView = (TextView)findViewById(R.id.text_notuse); textView.requestFocus();