Android:使用 WebView.loadUrl 加载 JavaScript 但保留软键盘
当用户单击 WebView
中的 (html) Textfield
时,将显示软键盘。 但是当我使用 WebView.loadUrl()
加载一些 JS 时,软键盘消失了。
我理解加载新页面时的行为。但是如何在加载 JS 时更改 WebView
的行为呢?
还有其他加载JS的方法吗?
我也尝试过手动操作键盘。但缺点也太多了。 确定键盘是否显示很复杂。我必须改变我的布局: 如何检查 Android 中软件键盘的可见性?
并且键盘将不再受 WebView
的控制。
Q:如何将JS加载到WebView中,而不影响软键盘?
When a user click on a (html) Textfield
in a WebView
, the soft keyboard is shown.
But when I load some JS with WebView.loadUrl()
the soft keyboard disappears.
I understand the behaviour when you load a new page. But how can I change the behaviour of the WebView
when loading JS?
Is there another way to load JS?
I also tried to handle the keyboard manually. But there are too many drawbacks.
It is complicated to determine if the keyboard is shown. And I would have to change my layout:
How to check visibility of software keyboard in Android?
And the keyboard would not be in the control of the WebView
anymore.
Q: How to load JS into a WebView, without affecting the soft keyboard?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
加载 javascript 后,再次将焦点集中到文本字段。这将解决问题。对于给予焦点这个讨论会很有帮助。
享受 :)
After loading javascript give focus to textfield again. That will solve problem. For giving focus this discussion will be helpful.
Enjoy :)