How does android use programs to turn off/on the keyboard

  android, question

There was originally an editText, and this keyboard will come out when editing. I want to set a button myself and then hide the keyboard.

Use InputMethodManager.

The main codes are as follows (available for pro-testing, for reference only):

public class MainActivity extends Activity {
    private Boolean isShow = false ;
	
    EditText editText;  
    InputMethodManager imm;
	
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        
        editText = (EditText) findViewById(R.id.editText);
        
        imm = 
(InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
        
        Button showHideBtn = (Button) findViewById(R.id.show_hide_btn);
        showHideBtn.setOnClickListener(new OnClickListener() {
		@Override
		public void onClick(View arg0) {
			if (isShow) {
				isShow = false;
				imm.showSoftInput(editText, InputMethodManager.SHOW_FORCED);
			} else {
				isShow = true;				imm.hideSoftInputFromWindow(editText.getWindowToken(), 0);
			}
		}
	});
    }
}

Official documents are as follows:http://developer.android.com/referenc …