I am trying to show a circular indeterminate loading indicator for a webView however despite reading a load of answers on here, my builds are failing. I get the error java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.ProgressBar.setVisibility(int)' on a null object reference. I have set up the progress bar in the fragment.xml file like so:
<ProgressBar
    android:id="@+id/prgrsbar"
    style="?android:attr/progressBarStyleLarge"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_centerHorizontal="true"
    android:layout_centerVertical="true"
    android:visibility="gone"
    android:indeterminateDrawable="@drawable/progress" >
</ProgressBar>
and created an empty progress.xml file in drawable with this in it:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
</selector>
Finally, here is my fragment's onCreateView activity code that I am using:
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    //code here
    View rootView = inflater.inflate(R.layout.fragment_first, container, false);
    String url = "http://winn-brown.co.uk/shmee/";
    WebView view = (WebView) rootView.findViewById(R.id.webview);
    view.getSettings().setJavaScriptEnabled(true);
    view.loadUrl(url);
    view.setWebViewClient(new WebViewClient() {
        private ProgressBar prgrsBar;
        public void onPageStarted(WebView view, String url, Bitmap favicon) {
            super.onPageStarted(view, url, favicon);
            prgrsBar.setVisibility(View.VISIBLE);
        }
        public void onPageFinished(WebView view, String url) {
            // do your stuff here
            Log.i("message", "website loaded");
        }
    });
    return rootView;
}
On this line private ProgressBar prgrsBar; it says "Private field 'prgrsBar' is never assigned, despite having the id in the fragment's xml file. Apologies if I am missing something obvious here.
 
     
     
    