Guest User

Untitled

a guest
Jan 16th, 2019
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  1. class MainActivity : AppCompatActivity() {
  2.  
  3. override fun onCreate(savedInstanceState: Bundle?) {
  4. super.onCreate(savedInstanceState)
  5. setContentView(R.layout.activity_main)
  6.  
  7. hideKeyboard(this)
  8. }
  9.  
  10. private fun hideKeyboard(activity: Activity) {
  11. val imm = activity.getSystemService(Activity.INPUT_METHOD_SERVICE) as InputMethodManager
  12. var view = activity.currentFocus
  13. if (view == null) {
  14. view = View(activity)
  15. }
  16. imm.hideSoftInputFromWindow(view.windowToken, 0)
  17. }
  18.  
  19. }
Add Comment
Please, Sign In to add comment