Moments of growth

[Kotlin] EditText 키보드 내리기 본문

Android [Kotlin] 💻🤍

[Kotlin] EditText 키보드 내리기

뮤링이 2022. 7. 5. 23:23

Fragment에서 키보드 내리는 코드

val imm = context!!.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
imm.hideSoftInputFromWindow(binding.etToWho.windowToken, 0)

 

Activity에서 키보드 내리는 코드

val imm = this.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
imm.hideSoftInputFromWindow(binding.etToWho.windowToken, 0)

InputMethodManager인 imm을 먼저 만들어줘야한다.

 

 

참고)

 

⌨️ EditText 키보드 올리기/내리기 (Kotiln)

먼저, InputMethodManager인 imm을 만들어 줍니다. val imm = this.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager 키보드 올리기 imm.showSoftInput(binding.etSearchAddress, 0) 키보드..

jsue.tistory.com

 

Comments