Android: how to permanently & completely NOT show default soft keyboard for an EditText?

前端 未结 2 845
囚心锁ツ
囚心锁ツ 2021-02-09 16:33

I have three EditText boxes in an activity, for two of which normal input methods (hard keys, default soft keyboard) are ok. But for one of the EditText boxes I want to send sof

2条回答
  •  日久生厌
    2021-02-09 17:28

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

    where SearchBox is your textbox or better yet instead of SearchBox get your current displayed window.

    Or try:

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

    where context is getApplicationContext();

提交回复
热议问题