Back to project page KnightNews_Android.
The source code is released under:
Copyright (c) 2014, James Van Gaasbeck All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are m...
If you think the Android project KnightNews_Android listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package knightnews.android; /*from w w w .ja va 2s. com*/ 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.WebChromeClient; import android.webkit.WebView; import android.webkit.WebViewClient; import android.widget.ProgressBar; import android.widget.TextView; /** * Created by jjvg on 5/26/14. */ public class SportsFragment3 extends Fragment { private static final String TAG = "SportsFragment"; private static final String URL = ""; private WebView mWebView; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setRetainInstance(true); } @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View v = inflater.inflate(R.layout.fragment_sports, container, false); final ProgressBar progressBar = (ProgressBar) v.findViewById(R.id.progressBar); progressBar.setMax(100); final TextView titleTextView = (TextView) v.findViewById(R.id.titleTextView); mWebView = (WebView) v.findViewById(R.id.webView); mWebView.getSettings().setJavaScriptEnabled(true); mWebView.setWebViewClient(new WebViewClient() { @Override public boolean shouldOverrideUrlLoading(WebView view, String url) { return false; } }); mWebView.setWebChromeClient(new WebChromeClient() { @Override public void onProgressChanged(WebView view, int newProgress) { if (newProgress == 100) { progressBar.setVisibility(View.INVISIBLE); } else { progressBar.setVisibility(View.VISIBLE); progressBar.setProgress(newProgress); } } @Override public void onReceivedTitle(WebView view, String title) { titleTextView.setText(title); } }); mWebView.loadUrl(URL); return v; } }