是否可以在没有点击或触摸事件的情况下在 Android 上打开键盘?例如,在将 textarea 附加到某个元素之后? element.focus() 适用于 iOS,但不适用于 Android。
最佳答案
只需将 "requestFocus" 添加到您的 XML 中。有点像
<EditText
android:id="@+id/editText"
... />
<requestFocus />
并在 onCreate()
this.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
或者: 可能只是
editText.requestFocus();
this.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
关于javascript - 如何在没有点击或触摸事件的情况下通过javascript在Android上打开键盘?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27835448/