Android dismiss keyboard

后端 未结 9 634
面向向阳花
面向向阳花 2021-01-29 23:51

How do I dismiss the keyboard when a button is pressed?

9条回答
  •  渐次进展
    2021-01-30 00:22

    You want to disable or dismiss a virtual Keyboard?

    If you want to just dismiss it you can use the following lines of code in your button's on click Event

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

提交回复
热议问题