EditText自动弹出软键盘

 1         editText.requestFocus()
 2         editText.isFocusable = true
 3         editText.isFocusableInTouchMode = true
 4         val timer = Timer()
 5         timer.schedule(object : TimerTask() {
 6             override fun run() {
 7                 if (editText != null) {
 8                     val imm = this@MainActivity.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
 9                     imm.toggleSoftInput(0, InputMethodManager.SHOW_FORCED)
10                 }
11             }
12         }, 200)

 

posted @ 2018-04-06 22:40  程小白  阅读(2594)  评论(0编辑  收藏  举报