Skip to content

Instantly share code, notes, and snippets.

@bassaer
Created April 23, 2018 12:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bassaer/ec4f6035674b34e871f5cf9d6bf87c05 to your computer and use it in GitHub Desktop.
Save bassaer/ec4f6035674b34e871f5cf9d6bf87c05 to your computer and use it in GitHub Desktop.
Androidでキーボードを閉じる方法メモ ref: https://qiita.com/bassaer/items/0e412d9f36b2113ee8d0
class ContentFragment : Fragment() {
private fun hideKeyboard() {
val view = activity.currentFocus
if (view != null) {
val manager = activity.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
manager.hideSoftInputFromWindow(view.windowToken, 0)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment