调用使用loadURL当机器人的WebView启动浏览器 [英] Android webview launches browser when calling loadurl
问题描述
我创建了一个活动
,有一个标题和一个的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:
<一个href="http://stackoverflow.com/questions/2378800/android-webview-click-opens-default-browser">Clicking网址打开默认浏览器
它指向的WebView
的教程:
<一href="http://developer.android.com/resources/tutorials/views/hello-webview.html">http://developer.android.com/resources/tutorials/views/hello-webview.html
只需实现Web客户端进行设置。
Just implement the web client and set it.
推荐答案
回答的基础上,从Maudicus和打的建议,我的问题。
Answering my question based on the suggestions from Maudicus and Hit.
检查的WebView教程在这里:<一href="http://developer.android.com/resources/tutorials/views/hello-webview.html">http://developer.android.com/resources/tutorials/views/hello-webview.html
Check the WebView tutorial here: http://developer.android.com/resources/tutorials/views/hello-webview.html
只需实现Web客户端,并将其设置的使用loadURL之前。最简单的方法是:
Just implement the web client and set it before loadUrl. The simplest way is:
myWebView.setWebViewClient(new WebViewClient());
有关的网页内容更先进的加工,考虑ChromeClient。
For more advanced processing for the web content, consider the ChromeClient.
这篇关于调用使用loadURL当机器人的WebView启动浏览器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!