-1

LOGCAT ERROR REPORT

02-20 10:46:13.344 7295-7295/seacoders.abhilash.bogguru E/dalvikvm: Could not find class 'android.support.v4.widget.DrawerLayout$1', referenced from method android.support.v4.widget.DrawerLayout.<init>

02-20 10:46:13.352 7295-7295/seacoders.abhilash.bogguru E/dalvikvm: Could not find class 'android.view.WindowInsets', referenced from method android.support.v4.widget.DrawerLayout.onDraw

02-20 10:46:13.354 7295-7295/seacoders.abhilash.bogguru E/dalvikvm: Could not find class 'android.view.WindowInsets', referenced from method android.support.v4.widget.DrawerLayout.onMeasure

02-20 10:46:13.356 7295-7295/seacoders.abhilash.bogguru E/dalvikvm: Could not find class 'android.view.WindowInsets', referenced from method android.support.v4.widget.DrawerLayout.onMeasure

02-20 10:46:13.424 7295-7295/seacoders.abhilash.bogguru E/dalvikvm: Could not find class 'android.graphics.drawable.RippleDrawable', referenced from method android.support.v7.widget.AppCompatImageHelper.hasOverlappingRendering

02-20 10:46:14.055 7295-7295/seacoders.abhilash.bogguru E/AndroidRuntime: FATAL EXCEPTION: main
                                                                          java.lang.NullPointerException
                                                                              at seacoders.abhilash.bogguru.HomeFragment$MyWebViewClient.onPageStarted(HomeFragment.java:55)
                                                                              at android.webkit.CallbackProxy.handleMessage(CallbackProxy.java:331)
                                                                              at android.os.Handler.dispatchMessage(Handler.java:107)
                                                                              at android.os.Looper.loop(Looper.java:194)
                                                                              at android.app.ActivityThread.main(ActivityThread.java:5371)
                                                                              at java.lang.reflect.Method.invokeNative(Native Method)
                                                                              at java.lang.reflect.Method.invoke(Method.java:525)
                                                                              at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:833)
                                                                              at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600)
                                                                              at dalvik.system.NativeStart.main(Native Method)

FRAGMENTHOME.java

package seacoders.abhilash.bogguru;

import android.graphics.Bitmap;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v4.view.GravityCompat;
import android.support.v4.widget.DrawerLayout;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.ProgressBar;
import android.widget.TextView;

public class HomeFragment extends Fragment {
    private WebView wv;
    private TextView txt;
    ProgressBar pbar;

    public static final String TITLE = "Home";

    public static HomeFragment newInstance() {

        return new HomeFragment();
    }

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, Bundle savedInstanceState) {
        //return inflater.inflate(R.layout.fragment_home, container, false);
        View v=inflater.inflate(R.layout.fragment_home, container, false);
        wv = (WebView)v.findViewById(R.id.webview);
        wv.loadUrl("http://www.google.com");
        WebSettings webSettings = wv.getSettings();
        webSettings.setJavaScriptEnabled(true);
        pbar = (ProgressBar) container.findViewById(R.id.pg1);
        txt = (TextView) container.findViewById(R.id.txtload);
        wv.setWebViewClient(new MyWebViewClient());
        return v;
    }

    public class MyWebViewClient extends WebViewClient {

        public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
            wv.loadUrl("file:///android_asset/error.html");
        }

        @Override
        public void onPageStarted(WebView view, String url, Bitmap favicon) {
            super.onPageStarted(view, url, favicon);
            System.out.println("loading... please wait");
            pbar.setVisibility(View.VISIBLE);
            txt.setVisibility(View.VISIBLE);
        }

        @Override
        public void onPageFinished(WebView view, String url) {
            System.out.println("finished loading");
            pbar.setVisibility(View.GONE);
            txt.setVisibility(View.GONE);
        }
    }

}
duggu
  • 37,851
  • 12
  • 116
  • 113

1 Answers1

1

Problem at below lines

   pbar = (ProgressBar) container.findViewById(R.id.pg1);
   txt = (TextView) container.findViewById(R.id.txtload);

You are called findViewById method on container,You should call v instead of container.

Solution

   pbar = (ProgressBar) v.findViewById(R.id.pg1);
   txt = (TextView) v.findViewById(R.id.txtload);

Thanks

Rajasekaran M
  • 2,478
  • 2
  • 20
  • 30