Code for Android Web view using with Fragment

import android.annotation.SuppressLint;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.ProgressBar;
import android.webkit.WebChromeClient;

@SuppressLint("SetJavaScriptEnabled")
public class Layout1 extends Fragment {
WebView webView;
private ProgressBar progressBar;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
            Bundle savedInstanceState) {
      
View v = inflater.inflate(R.layout.layout1, container, false);
               
       
  WebView wv = (WebView) v.findViewById(R.id.webView1);
  wv.getSettings().setJavaScriptEnabled(true);
  wv.setWebViewClient(new SwAWebClient());
  wv.loadUrl("http://www.google.com");
       
webView.setWebChromeClient(new WebChromeClient() {
                                          


public void onProgressChanged(WebView view, int progress)                                
{                                             
progressBar.setProgress(progress);
                                        
}});
                   
return v;
}
   
private class SwAWebClient extends WebViewClient {                   
@Override                  
 public boolean shouldOverrideUrlLoading(WebView view, String url) {                   
  return false;           
}     
 }

}

Comments

Popular posts from this blog

How to prepare your PC for the Windows 10 upgrade Source: WC

Top 5 Japanese Anime (Cartoons)

TOP FREE ANTIVIRUS