如何在新标签android webview中打开链接? [英] How to open links in new tab android webview?

查看:38
本文介绍了如何在新标签android webview中打开链接?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 webview 创建了一个 android 应用程序来显示我的网站,我什至想添加在新选项卡中打开链接的功能,但我找不到任何关于它的指南.我认为可以使用的想法是,检查用户是否长按,显示菜单选项以在新选项卡中打开或打开,打开将简单地打开并在新选项卡中打开将在新活动中打开,但如何再次查看打开的活动?长按不会影响文本吗?请帮帮我.

I have created a android app using webview to display my site, i even want to add the functionality to open the link in new tab but I can't find any guides on it. The idea am thinking which can be used is, check if user long clicks, present menu options to open or open in new tab, open will simply open and open in new tab will open in new activity, but how to see the open activities again? And won't the long press affect the text as well? Please help me.

推荐答案

是的,您可以在应用中创建多个选项卡.我希望所有选项卡都是同一活动的一部分,您可以选择片段或简单地单独 WebViews 来保存每个选项卡的内容.标签导航也将由您的活动负责.

Yes you can create multiple tabs in your app. I would expect all tabs be parts of the same activity, you can choose fragments or simply separate WebViews to hold the contents for each tab. Tab navigation will be responsibility of your activity, too.

如果您愿意,您也可以在外部浏览器"中打开一些链接.

You can also open some links in "external browser", if that is your intention.

无论如何,您的 javascript 将处理首页上的用户操作,并且可以将自定义事件发送到 Android 应用程序,该应用程序将负责替换当前 WebView 的内容、打开另一个(选项卡)WebView,或发送另一个(浏览器)应用程序的 URL.

At any rate, your javascript will handle user actions on the front page and it can send custom events to the Android app, which will be responsible for replacing the content of current WebView, opening another (tab) WebView, or sending the URL to another (browser) app.

这篇关于如何在新标签android webview中打开链接?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆