2015-02-10 32 views
0

我想僅在應用程序中顯示任何網頁,而不是在瀏覽器中顯示。 我已經使用了下面的代碼,但它會打開瀏覽器。如何僅在Android應用程序中顯示android中的網頁

web = (WebView)findViewById(R.id.web_vieww); 
web.loadUrl("http://www.google.co.in/"); 
+0

你應該設置爲WebViewClient用的WebView中重寫'用的WebView避免對重定向或我已經使用這個還沒有,但工作的任何鏈接點擊或網頁視圖網址 – 2015-02-10 07:54:52

+0

的變化打開默認瀏覽器shouldOverrideUrlLoading' .. 。web.setWebViewClient(新WebViewClient(){ \t \t @覆蓋 \t \t公共布爾shouldOverrideUrlLoading(的WebView視圖,字符串URL) \t \t { \t \t \t url =「http://www.google.co.in」; \t \t view.loadUrl(url); \t \t return true; \t \t} \t \t}); – abhi 2015-02-10 07:56:00

+0

不工作意味着什麼?因爲同樣工作正常,當我試着 – 2015-02-10 08:05:22

回答

0
web = (WebView)findViewById(R.id.web_vieww); 
web.loadUrl("http://www.google.co.in/"); 
web.setWebViewClient(new MyWebViewClient()); 

Define MyWebViewClient(); 

private class MyWebViewClient extends WebViewClient { 

    @Override 

    public boolean shouldOverrideUrlLoading(WebView view, String url) { 

     return false; 
    } 
} 
相關問題