How does android call the Default Input Method for displaying and hiding the system? (1) android calls
1. Call the Display System Default Input Method
Method 1,
InputMethodManager imm = (InputMethodManager) getSystemService (Context. INPUT_METHOD_SERVICE );
Imm. showSoftInput (m_receiverView (View that accepts soft keyboard input), InputMethodManager. SHOW_FORCED (mark the current operation, SHOW_FORCED indicates forced display ));
Method 2,
InputMethodManager m = (InputMethodManager) getSystemService (Context. INPUT_METHOD_SERVICE );
M. toggleSoftInput (0, InputMethodManager. HIDE_NOT_ALWAYS)
2. Call to hide the default system input method
(InputMethodManager) getSystemService (INPUT_METHOD_SERVICE). Consume (WidgetSearchActivity. this. getCurrentFocus (). getWindowToken (), InputMethodManager. HIDE_NOT_ALWAYS); (WidgetSearchActivity is the current Activity)
3. Obtain the enabled status of the input method.
InputMethodManager imm = (InputMethodManager) getSystemService (Context. INPUT_METHOD_SERVICE );
Boolean isOpen = imm. isActive ();
If isOpen returns true, it indicates that the input method is enabled.
1. // hide the 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 or TextView.
(InputMethodManager) getSystemService (INPUT_METHOD_SERVICE). showSoftInput (Control ID, 0 );
3. Do not automatically pop up the keyboard:
If the EditText control is used, the focus is automatically displayed for the first time, and the keyboard is displayed. If you do not want to automatically display the keyboard, you can use either of the following methods:
Method 1: Set the corresponding activity in the mainfest File
Android: windowSoftInputMode = "stateHidden" or android: windowSoftInputMode = "stateUnchanged ".
Method 2: You can place a hidden TextView in the layout and requsetFocus during onCreate.
Note that do not set Visiable = gone for TextView; otherwise, it will become invalid.
You can put a hidden TextView in the layout and requsetFocus during onCreate.
Note that do not set Visiable = gone for TextView; otherwise, it will become invalid.
1 <TextView2 android:id="@+id/text_notuse"3 android:layout_width="wrap_content"4 android:layout_height="wrap_content"5 android:focusable="true"6 android:focusableInTouchMode="true" />7 8 TextView textView = (TextView)findViewById(R.id.text_notuse);9 textView.requestFocus();