EditText in PopupWindow not showing keyboard even if setFocusable(true)

前端 未结 5 937
小鲜肉
小鲜肉 2020-12-17 10:28

I can\'t seem to get this work. I already set popWindow focusable as to what I read on other forums but still no luck.

xml



        
5条回答
  •  不知归路
    2020-12-17 10:54

    Nothing helped me, it still didn't appear on some devices, so I had to force showing it like that (kotlin):

    val editText = customView.findViewById(numberFieldId)
            editText.onClick {
                showKeyboard(editText, context)
            }
    
    private fun showKeyboard(mEtSearch: EditText, context: Context) {
            mEtSearch.requestFocus()
            val imm = context.getSystemService(Activity.INPUT_METHOD_SERVICE) as InputMethodManager
            imm.toggleSoftInput(InputMethodManager.HIDE_IMPLICIT_ONLY, 0)
        }
    

提交回复
热议问题