简体   繁体   中英

Android: show/hide the android soft keyboard

How can I disable and enable the virtual keyboard when the user click on the EditText. If I use the instruction EditText.setInputType(InputType.TYPE_NULL); the cursor does not blink and when I set it not focusable the cursor disappear.

Force open soft keyboard

((InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE)).toggleSoftInput(InputMethodManager.SHOW_FORCED, InputMethodManager.HIDE_IMPLICIT_ONLY);

Force close soft keyboard

((InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE)).hideSoftInputFromWindow(_pay_box_helper.getWindowToken(), 0);

Hope to work...

InputMethodManager imm = (InputMethodManager)getActivity().getSystemService(
          Context.INPUT_METHOD_SERVICE);
    imm.hideSoftInputFromWindow(your_edittext.getWindowToken(), 0);
    imm.showSoftInputFromWindow(your_edittext.getWindowToken(), 0);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM