Show soft keyboard when Activity starts

前端 未结 10 602
梦毁少年i
梦毁少年i 2020-12-13 08:28

I have 2 activities, A and B. When A starts, it checks for a condition and if true, it calls startActivityForResult() to start B. B only takes text input so it

10条回答
  •  渐次进展
    2020-12-13 08:35

    Major Attention Required!

    android:windowSoftInputMode="stateVisible|adjustPan" This alone won't work to show keyboard on activity start.

    You also need to explicitly add this into your class

    editTextXYZ.requestFocus()
            val imm: InputMethodManager =
                getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
            imm.showSoftInput(editTextXYZ, InputMethodManager.SHOW_IMPLICIT)
    

提交回复
热议问题