问题
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