Android webview launches browser when calling loadurl

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:

Clicking URLs opens default browser

It points to the WebView tutorial here.

Just implement the web client and set it.


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

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

myWebView.setWebViewClient(new WebViewClient());

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


用这个:

lWebView.setWebViewClient(new WebViewClient());

像这样使用:

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_dedline);

    WebView myWebView = (WebView) findViewById(R.id.webView1);
    myWebView.setWebViewClient(new WebViewClient());
    myWebView.loadUrl("https://google.com");
}
链接地址: http://www.djcxy.com/p/93368.html

上一篇: 防止Android上的全屏虚拟键盘(Adobe Air应用程序)

下一篇: 调用loadurl时,Android webview会启动浏览器