Android WebView not loading URL

前端 未结 10 938
鱼传尺愫
鱼传尺愫 2020-12-05 02:15

I want to load the URL in WebView

I have used the following Code:

webView = (WebView) findViewById(R.id.webview1);
webView.setWebViewCli         


        
10条回答
  •  醉酒成梦
    2020-12-05 02:36

    Did you added the internet permission in your manifest file ? if not add the following line.

      
    

    hope this will help you.

    EDIT

    Use the below lines.

    
        public class WebViewDemo extends Activity {
    
    
            private WebView webView;
    
    
            Activity activity ;
            private ProgressDialog progDailog; 
    
            @SuppressLint("NewApi")
            @Override
            public void onCreate(Bundle savedInstanceState) {
                super.onCreate(savedInstanceState);
                setContentView(R.layout.main);
    
                activity = this;
    
                progDailog = ProgressDialog.show(activity, "Loading","Please wait...", true);
                progDailog.setCancelable(false);
    
    
    
               webView = (WebView) findViewById(R.id.webview_compontent);
    
    
    
               webView.getSettings().setJavaScriptEnabled(true);     
               webView.getSettings().setLoadWithOverviewMode(true);
               webView.getSettings().setUseWideViewPort(true);        
                webView.setWebViewClient(new WebViewClient(){
    
                    @Override
                    public boolean shouldOverrideUrlLoading(WebView view, String url) {
                        progDailog.show();
                        view.loadUrl(url);
    
                        return true;                
                    }
                    @Override
                    public void onPageFinished(WebView view, final String url) {
                        progDailog.dismiss();
                    }
                });
    
                webView.loadUrl("http://www.teluguoneradio.com/rssHostDescr.php?hostId=147");
    
               }
        }
    

提交回复
热议问题