2014-11-08 146 views
0

我是新来的android programing.my问题是,在我的webview,当我点击任何链接其打开一个新的web浏览器我不需要这个我希望它被打开在我的应用程序本身。有人帮助我?webview链接打开到默认浏览器

这是我的代码

title = extras.getString("title"); 
    url = extras.getString("url"); 
    TextView text=(TextView) findViewById(R.id.textView1); 
    text.setText(title); 
    WebView myWebView =(WebView)findViewById(R.id.WebView); 
    myWebView.getSettings().setJavaScriptEnabled(true); 
    myWebView.setWebViewClient(new WebViewClient(){ 
     public boolean shouldOverrideUrlLoading(WebView view, String url) { 
      view.loadUrl(url); 
      return false; 
     } 
    }); 
    } 

我试过,但我的web视图没有加载它显示一个空白屏幕

+0

检查此链接http://www.tutorialspoint.com/android/ android_webview_layout.htm – Piyush 2014-11-08 04:45:41

+0

检查这个http://www.technotalkative.com/android-webviewclient-example/ – 2014-11-08 04:45:55

+0

感谢你的回复..它的工作完美.. – 2014-11-08 05:15:07

回答

0
web = (WebView) findViewById(R.id.webview01); 
    web.setWebViewClient(new myWebClient()); 
    web.getSettings().setJavaScriptEnabled(true); 
    web.loadUrl("http://www.google.com"); 

    public class myWebClient extends WebViewClient 
    { 
    @Override 
    public void onPageStarted(WebView view, String url, Bitmap favicon) { 
     // TODO Auto-generated method stub 
     super.onPageStarted(view, url, favicon); 
    } 

    @Override 
    public boolean shouldOverrideUrlLoading(WebView view, String url) { 
     // TODO Auto-generated method stub 

     view.loadUrl(url); 
     return true; 

    } 
} 
+0

请提供一些信息,你在你的代码完成。 – 2014-11-08 04:54:48

+0

thanku ...我错过了添加myWebView.loadUrl(url);这一行上面的方法。 – 2014-11-08 05:14:20

相关问题