How to open links in new tab android webview? [closed]

北城以北 提交于 2019-12-20 07:47:30

问题


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.


回答1:


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.

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.




回答2:


There's no such thing as tabs in a WebView. It sounds like you should just build a website and skip building an Android app wrapper around a website.



来源:https://stackoverflow.com/questions/38034769/how-to-open-links-in-new-tab-android-webview

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!