Android:使用 WebView.loadUrl 加载 JavaScript 但保留软键盘

发布于 2024-12-12 09:29:32 字数 463 浏览 4 评论 0原文

当用户单击 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

二智少女 2024-12-19 09:29:32

加载 javascript 后,再次将焦点集中到文本字段。这将解决问题。对于给予焦点这个讨论会很有帮助。

享受 :)

After loading javascript give focus to textfield again. That will solve problem. For giving focus this discussion will be helpful.

Enjoy :)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文