如何在Android应用程序中显示外部HTML/网页? [英] How to show external html / web pages inside android app?
问题描述
我正在尝试创建一个Android应用,该应用将根据用户的选择向用户显示多个网址.如果用户单击链接,则我希望外部网站在我的应用程序中打开,以便用户在访问侧面后可以轻松返回其他链接.我正在使用Web视图,并且每次打开浏览器时都不需要.由于有时用户很难返回到应用程序.我想要在框架内打开网页之类的东西.
I am trying to create an android app which will show multiple web urls to users based on their choice. If a user clicks on a link I want the external website to open inside my app so that user can easily go back to other links after visiting the side. I am using web view and each time it is opening a browser , which I don't want. As sometimes it is difficult for user to go back to app. I want something like a web page opening inside a frame .
我在活动中使用以下代码.
I am using the following code in my activity.
webView = (WebView) findViewById(R.id.webview);
webView.loadUrl(url);
在此先感谢您的帮助.沙克蒂
Thanks in advance for any help . Shakti
推荐答案
是的,那么您需要创建 WebViewClient.
Yes then you need to create WebViewClient.
private class HelloWebViewClient extends WebViewClient {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
view.loadUrl(url);
return true;
}
}
检查 Hello WebView示例中给出的第7和第8步..
Check Step No. 7 and 8 given in Hello WebView example..
这篇关于如何在Android应用程序中显示外部HTML/网页?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!