调用loadurl时Android webview启动浏览器 [英] Android webview launches browser when calling loadurl

查看:49
本文介绍了调用loadurl时Android webview启动浏览器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个 Activity,它在 LinearLayout 中有一个标题和一个 web 视图.在 onResume() 方法中,它调用 webView.loadUrl(url).问题在于,活动首先显示标题,屏幕的其余部分为空白,然后设备浏览器会使用 URL 页面启动.我想看到的是在标题下方的 WebView 中显示的页面.可能是什么问题?

I created an Activity that has a title and a web view in a LinearLayout. In the onResume() method it calls webView.loadUrl(url). The problem is that the activity first shows the title with the rest of the screen blank, then the device browser is launched with the page for the URL. What I want to see is the page being shown in the WebView below the title. What could be the problem?

编辑:好的,做了一些进一步的搜索,找到了这个:

Edit: Ok, did some further search and found this one:

点击 URL 打开默认浏览器

它指向 WebView 教程 这里.

只需实现 Web 客户端并进行设置即可.

Just implement the web client and set it.

推荐答案

根据 Maudicus 和 Hit 的建议回答我的问题.

Answering my question based on the suggestions from Maudicus and Hit.

此处查看 WebView 教程.只需实现 Web 客户端并在 loadUrl 之前设置它.最简单的方法是:

Check the WebView tutorial here. Just implement the web client and set it before loadUrl. The simplest way is:

myWebView.setWebViewClient(new WebViewClient());

要对 Web 内容进行更高级的处理,请考虑使用 ChromeClient.

For more advanced processing for the web content, consider the ChromeClient.

这篇关于调用loadurl时Android webview启动浏览器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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