2014-11-08 100 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

相關問題