Android: Hiding the keyboard in an overridden “Done” keypress of EditText

前端 未结 4 486
一向
一向 2020-12-30 06:17

I have used a bit of Android code to override the \"Done\" button in my EditText field:

   myEditField.setOnEditorActionListener(new TextView.OnEditorActionL         


        
4条回答
  •  南方客
    南方客 (楼主)
    2020-12-30 07:06

    You can close the keyboard by doing:

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

提交回复
热议问题