Hide Soft keyboard on return key press

前端 未结 9 1243
[愿得一人]
[愿得一人] 2020-12-29 19:00

I\'ve searched half a dozen other answers on SO, but haven\'t found one that works. All I\'m trying to do is dismiss the soft keyboard when the user presses the enter butto

9条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-29 19:35

    Based on my tests, what is really required to dismiss the soft keyboard, when a user clicks the enter button, can be achieved simply by adding the code below to your EditText in xml.

    android:imeOptions="actionDone"
    android:inputType="textImeMultiLine"
    

    No need for OnEditorActionListener or any other Java code.

提交回复
热议问题