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

前端 未结 2 844
囚心锁ツ
囚心锁ツ 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:18

    Simple

    editText.setShowSoftInputOnFocus(false);
    

    Some people suggested that the following might work on older versions of Android, but the behaviour is unexpected.

    edittextPlay.setTextIsSelectable(true);
    
    0 讨论(0)
  • 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();

    0 讨论(0)
提交回复
热议问题